Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| voter_list = pd.read_excel("./source_data/Voter File - Newport - 06-29-2018/Voter File - Newport - 06-29-2018.xlsx", | |
| dtype={'ZIP CODE': 'str', | |
| 'STREET NUMBER': 'str', | |
| 'MAILING STREET NUMBER': 'str', | |
| 'MAILING ZIP CODE': 'str', | |
| 'CONGRESSIONAL DISTRICT': 'str', | |
| 'STATE SENTATE DISTRICT': 'str', | |
| 'STATE REP DISTRICT': 'str', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # an inelegant script to melt state data into files for SUMO model | |
| import pandas as pd | |
| def build_od_list(od_file): | |
| od = pd.read_csv(od_file, header=None, index_col=0) | |
| od.columns = od.index | |
| # clean matrix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; extending random walk 2d example into 3d | |
| turtles-own | |
| [ | |
| xc ; next x coordinate | |
| yc ; next y coordinate | |
| zc ; next z coordinate | |
| ] | |
| to setup | |
| clear-all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import pandas as pd | |
| # API documentation is at https://www.ncdc.noaa.gov/cdo-web/webservices/v2 | |
| NOAA_API_TOKEN = '<from NOAA>' | |
| headers = {'token':NOAA_API_TOKEN} | |
| # get stations in Newport, RI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from PIL import Image | |
| from io import BytesIO | |
| import os | |
| import pandas as pd | |
| # get crosswalk dataset | |
| newport_crossings_url = 'https://raw.githubusercontent.com/NewportDataPortal/sidewalk-map/development/npt-sidewalk-street-intersections.geojson' | |
| crossing_response = requests.get(newport_crossings_url) | |
| crossing_json = crossing_response.json() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from PIL import Image | |
| from io import BytesIO | |
| import json | |
| url = 'https://maps.googleapis.com/maps/api/streetview' | |
| key = STREETVIEW_API_KEY | |
| out_file = 'streetviewimg.jpg' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import shapefile | |
| import geopandas as gp | |
| def convert_shapefile(filepath, crs=None): | |
| # Function to read an ESRI shapefile and return a geopandas GeoDataFrame | |
| reader = shapefile.Reader(filepath) | |
| # Extract the column names for the data | |
| fields = reader.fields[1:] | |
| field_names = [field[0] for field in fields] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # snippet from github.com/geopy/geopy/blob/master/README.md | |
| from geopy.geocoders import Nominatim | |
| geolocator = Nominatim() | |
| location = geolocator.geocode("175 5th Avenue NYC") | |
| print(location.address) | |
| print((location.latitude, location.longitude)) |