Overwriting a Feature Layer from SpatialDataFrame Data Source

689
2
11-27-2018 08:51 AM
NathanielEvatt
New Contributor III

I am trying to update / overwrite a Feature Layer using the ArcGIS API for Python. 

I am currently loading and manipulating the data in a SpatialDataFrame and I have published the data using `sdf.spatial.to_featurelayer()`.  This function creates a shapefile and the resulting Feature Layer.  However, the data is going to be updating and changing on maybe a weekly basis.  I could delete the layer and simply recreate it, but there is a good chance that the layer will be part of a StoryMap or some other AGOL web map, so that is not an option.

There is a good tutorial on how to overwrite a Feature Layer using pandas and a CSV here: overwriting_feature_layers | ArcGIS for Developers , but this depends on having the data in CSV format and utilizes the pandas `read_csv()` method, which does not have read_shapefile() equivalent.  

The `manager.overwrite()` method does not accept SDF format (though that would be super cool), so I think the best way to do it is probably updating the underlying shapefile and then overwriting from there.  Any ideas on how to do that or any other ideas?

0 Kudos
2 Replies
NathanielEvatt
New Contributor III

In case anyone else tries to do the same, it turned out to be easier to simply update / add / delete using the edit_features functionality as described in the following ESRI guides: updating_features_in_a_feature_layer | ArcGIS for Developers  and Editing Features | ArcGIS for Developers 

Kind of a bummer because I need to manage all the data updates individually instead of simply rewriting, but this solution is definitely the most efficient.  

JanBurdziej
New Contributor III

Hi Nathaniel, thanks for sharing your feedback. Did you try to do the same with GeoJSON hosted Feature Layer? I'm trying to use flayer_collection.manager.overwrite()from the Jupyter notebook. I get the {'success': True} response, the modified date in AGOL metadata is updated but the actual data is still the same... I'm using a web GeoJSON ('http://www.gdacs.org/xml/archive.geojson').

Does anyone have any idea why the data is not getting updated? It gets updated without any problems via AGOL web interface...

Thanks,

Jan

0 Kudos