What is the recommended method to overwrite feature layer data using Python API?

538
2
Jump to solution
01-19-2024 02:15 AM
Labels (1)
A_Schwab
New Contributor III

I have a feature layer that I'm trying to update regularly with new data using the ArcGIS Online Python API.

The two methods I've found in ESRI docs are to create a featurelayer collection and use overwrite() or to use the Truncate and Append method.

The overwwrite() method doesn't change any of the data but says the operation is successful, so there's no indication why it hasn't worked.

The truncate and append method fails at calling append() with an unspecified 500 error.

I would love to know what the officially supported way to overwrite an existing layer on AGOL is, either from a spatially-enabled data frame or from a layer in a file geodatabase.

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Truncate and append is the method to use. Overwriting a feature service has historically led to problems.

Don't use the literal append() method, either. If you've got a spatial dataframe, you can just do

FeatureLayer.edit_features(adds=spatial_dataframe.spatial.to_featureset())
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Truncate and append is the method to use. Overwriting a feature service has historically led to problems.

Don't use the literal append() method, either. If you've got a spatial dataframe, you can just do

FeatureLayer.edit_features(adds=spatial_dataframe.spatial.to_featureset())
- Josh Carlson
Kendall County GIS
0 Kudos
A_Schwab
New Contributor III

Looks like `edit_features()` does what I need so I'll go ahead with that. Thanks for the info!

0 Kudos