I am trying to figure out how to update a feature service hosted on arcgis online using the arcgis api for python. Essentially, every morning I would like to run a script that takes new features from a feature class on our organizations egdb and update a replica of the feature service on AGOL.
Is this possible?
Solved! Go to Solution.
If you utilize the Python API from an IDE and pull in ArcPy functions as well, you can utilize adding/editing features:
You just need to create loop through your feature class to grab the pertinent attributes, format them for the ingestion into the Python API. Definitely possible.
I made a test data set and was able to successfully add a point using the python api. However, when i implement this into our GIS, I will be adding polygons. Would you know how to write the geometry (coordinates) for a polygon? Adding a point is pretty straight forward as it is just an x,y value.
Do you have to export your new data to a csv? Can you connect directly to your geodatabases using the Python API? Definitely easier utilizing just the ArcGIS API, but I can see numerous occasions where users would want to update directly from their authoritative databases.
You don't have to export your data to a csv.
You can overwrite feature layers using arcgis.features.managers module — arcgis 1.2.0 documentation
You can also read in a file geodatabase or shapefile as a Spatial Data Frame and get it in pandas before pushing the updates to a feature layer, on similar patterns as the examples shared above.
Thanks for the API. It is helpful.
Here is some advice for those attempting to use .overwrite(). If you are passing a string file path, try pointing to the zipfile name while dropping the '.zip'. This worked for me.