Created
March 30, 2023 03:05
-
-
Save thehappycheese/0b04aff72b16ac0320504713b84629ab to your computer and use it in GitHub Desktop.
Fetch arcgis rest open data as geopandas dataframe
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
#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