Skip to content

Instantly share code, notes, and snippets.

@thehappycheese
Created March 30, 2023 03:05
Show Gist options
  • Save thehappycheese/0b04aff72b16ac0320504713b84629ab to your computer and use it in GitHub Desktop.
Save thehappycheese/0b04aff72b16ac0320504713b84629ab to your computer and use it in GitHub Desktop.
Fetch arcgis rest open data as geopandas dataframe
#pip install pandas geopandas arcgis arcgis2geojson
import json
import geopandas as gpd
from geopandas import GeoDataFrame
from arcgis.features import FeatureLayer
from arcgis2geojson import arcgis2geojson
def get_arcgis_layer_as_geopandas(url:str) -> GeoDataFrame:
layer = FeatureLayer(url)
layer_feature_set = layer.query(out_sr=4326)
return gpd.read_file(
json.dumps(arcgis2geojson(layer_feature_set.to_dict())), driver="GeoJSON")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment