Last active
February 2, 2020 15:42
-
-
Save maptastik/6030df87e8bd62fa583a83ecea9fceab to your computer and use it in GitHub Desktop.
Pull GeoJSON from the toobz and create a GeoDataFrame
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, json, geopandas as gpd | |
def remoteGeoJSONToGDF(url, display = False): | |
"""Import remote GeoJSON to a GeoDataFrame | |
Keyword arguments: | |
url -- URL to GeoJSON resource on web | |
display -- Displays geometries upon loading (default: False) | |
""" | |
r = requests.get(url) | |
data = r.json() | |
gdf = gpd.GeoDataFrame.from_features(data['features']) | |
if display: | |
gdf.plot() | |
return gdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment