This file contains 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 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 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 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 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 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 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)) |