I'm trying to run a notebook script in AGOL that checks and fixes features with null geometry. The results from edit_features( ) operation indicates success, but the updates never appear in the feature layer. Any idea why this might be?
For parent features with null geometry, the script loops through related child features, unions their geometry, and replaces parent features' geometry with the unioned product.
from arcgis.gis import GIS
import arcgis
gis = GIS("home")
uas_fs_id = '09379d41ab3448549525914a4b08524a'
uas_fs = gis.content.get(uas_fs_id)
missions_layer = uas_fs.layers[0]
flights_layer = uas_fs.layers[1]
missions = missions_layer.query()
for mission in missions:
if mission.geometry is None:
mission_globalid= mission.get_value('globalid')
flights = flights_layer.query(where="parentglobalid='{}'".format(mission_globalid))
flights_geom = [flight.geometry for flight in flights]
unioned = arcgis.geometry.functions.union(spatial_ref={'wkid': 4326, 'latestWkid': 4326}, geometries=flights_geom, gis=gis)
mission.geometry = unioned
result = missions_layer.edit_features(updates=[mission])
print(result)
results:
{'addResults': [], 'updateResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': 'bcb70fa1-b009-4133-8f33-1a4d707274fe', 'success': True}], 'deleteResults': []}
{'addResults': [], 'updateResults': [{'objectId': 2, 'uniqueId': 2, 'globalId': 'd5067b60-7f2c-4ef8-8f6a-1c0afa9fae55', 'success': True}], 'deleteResults': []}
{'addResults': [], 'updateResults': [{'objectId': 3, 'uniqueId': 3, 'globalId': '260083d3-0834-4f31-81e5-fb7fca7d4aa7', 'success': True}], 'deleteResults': []}
It always says it succeeds, but never does anything. What gives?