I'm trying to use the set_value function on a feature in a feature layer hosted on AGOL. The set_value function seems to work and does not return an error but when I query the feature service none of the features have the updated values.
I set up a layer:
dataSearch = gis.content.search("pointService", "feature service")
for layer in dataSearch.layers:
if layer.properties.name == "pointService":
pointLayer = layer
Then I get the feature set for that layer:
updateFeatures = pointLayer.query()
Then I try to set the values of some attributes:
for feature in updateFeatures.features
The updated attributes show up when I use get_value()
But when I query the feature service from the REST endpoint or download it as a shapefile, the attributes are empty. I have tried using the refresh() method on the feature layer manager but it had no effect.
It looks you are not pushing the changes you made in-memory. Can you try this: call the `edit_features()` method on your FeatureLayer object, pass the changes to the `updates` parameter and then try to query using either the REST endpoint or download as shapefile.
The workflow for editing is explained here https://developers.arcgis.com/python/guide/editing-features/#Updating-features
Well that works - thanks. I also got it to work using the calculate() function on the feature layer.
What is the intended use of the set_value() function? Is there a method to push changes from in_memory?
The set_value() is powerful in that, you can use it to safely set or update not only attribute values of a feature but also its geometry. If you constructed your geometry as a
Polyline object say, you can call the set_value('geometry', your_polyline_obj) and the API takes care of updating the geometry.
Still, the changes are local. You need to call the update() as discussed earlier if you want to push them to the server and persist.