arcgis2geojson
raw JSON → 3.1.1 verified Mon Apr 27 auth: no python
A Python library for converting ArcGIS JSON (ESRI FeatureSet, Feature, Point, Polyline, Polygon, MultiPoint) to GeoJSON. Current version 3.1.1, requires Python >=3.10. Maintained, with regular releases.
pip install arcgis2geojson Common errors
error AttributeError: module 'arcgis2geojson' has no attribute 'arcgis2geojson' ↓
cause Import performed as 'import arcgis2geojson' but the function may not be directly accessible due to shadowing (unlikely in current version) OR incorrect installation.
fix
Ensure you have arcgis2geojson installed (pip list) and import as 'import arcgis2geojson' then use 'arcgis2geojson.arcgis2geojson'. Alternatively, do 'from arcgis2geojson import arcgis2geojson'.
error KeyError: 'geometryType' ↓
cause Input dictionary missing the required 'geometryType' key. This is mandatory for ArcGIS JSON.
fix
Make sure your ArcGIS JSON includes 'geometryType' (e.g., 'esriGeometryPoint', 'esriGeometryPolygon').
error TypeError: string indices must be integers ↓
cause Passed a JSON string (str) instead of a dict to arcgis2geojson().
fix
Parse the string first: import json; arcgis_json = json.loads(json_string); geojson = arcgis2geojson.arcgis2geojson(arcgis_json)
Warnings
gotcha The function arcgis2geojson() expects a Python dict (parsed from JSON), not a raw JSON string. If you have a string, you must parse it via json.loads() first. ↓
fix geojson = arcgis2geojson.arcgis2geojson(json.loads(arcgis_json_string))
gotcha ArcGIS JSON with spatialReference.wkid (e.g., 4326) is not automatically reprojected; the library assumes WGS84 (EPSG:4326). If your data is in a different CRS, you must reproject before conversion. ↓
fix Manually reproject coordinates using a library like pyproj before passing to arcgis2geojson.
deprecated The old experimental function 'convert' (from v2.x) was removed in v3.0. Use 'arcgis2geojson' function instead. ↓
fix Replace convert(...) with arcgis2geojson(...).
Imports
- arcgis2geojson
import arcgis2geojson - N/A wrong
from arcgis2geojson import ArcGIS2GeoJSONcorrectfrom arcgis2geojson import arcgis2geojson
Quickstart
import arcgis2geojson
# Convert an ArcGIS JSON FeatureSet (dict)
arcgis_json = {
"geometryType": "esriGeometryPoint",
"features": [{"attributes": {"id": 1}, "geometry": {"x": -122.68, "y": 45.52}}]
}
geojson = arcgis2geojson.arcgis2geojson(arcgis_json)
print(geojson)
# Output: {'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {'id': 1}, 'geometry': {'type': 'Point', 'coordinates': [-122.68, 45.52]}}]}