1

I would like to upload local GeoJSON files with Python automatically to ArcGIS Online. Now I have to upload them one for one, which takes quite some time. So I looked into the ArcGIS API for Python.

I saw two ways you can upload data to ArcGIS online:

  1. With help of the spatially enabled dataframe, but this seems to be only working with shapefiles or an ESRI database and not GeoJSON files or a Geopandas dataframe
  2. Using the add() method on a ContentManager instance, with this method you can upload a pandas DataFrame or a csv file to ArcGIS Online. However, I cannot figure out how you can upload a polygon feature layer. All the examples are with points.

Can someone provide me with a simple example of how to upload GeoJSON (polygons) or GeoPandas DataFrame to ArcGIS Online with Python?

2

This Esri Community question contains the answer.

To summarize (since the final solution is spread out over multiple answers):

from arcgis.gis import GIS

data_path = r'C:\path\example.geojson'
gis = GIS('https://arcgis.com', '<username>', '<password>')

item_properties = {'type': 'GeoJson', 'title': 'Test GeoJSON File', 'tags': 'test'}
item = gis.content.add(item_properties, data_path)
item.publish(file_type='geojson')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.