Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active February 2, 2020 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/6030df87e8bd62fa583a83ecea9fceab to your computer and use it in GitHub Desktop.
Save maptastik/6030df87e8bd62fa583a83ecea9fceab to your computer and use it in GitHub Desktop.
Pull GeoJSON from the toobz and create a GeoDataFrame
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