I am trying to update features in an AGOL feature layer in Python.
I am looping through some Json returning routers and then want to update the feature that matches the router ID
The example works below, but I can't figure out how to change router_feature = [f for f in router_features if f.attributes['id']==557159][0] to use a variable.
In the same vein, I need to update the geometry and setting a point works, but again I need to put in the new location values from the Json for x,y
pt = Point({"x" : -111.93345, "y" : 33.59674,
"spatialReference" : {"wkid" : 4326}})
search_result = gis.content.search('title:my Routers')
router_item = search_result[0]
search_result[0]router_item = search_result[0]
print (router_item)
router_layers = router_item.layers
router_layersrouter_fset = router_layers[0].query()
router_features = router_fset.features
router_flayer = router_layers[0]
router_flayer.properties.capabilitiesrouter_feature = [f for f in router_features if f.attributes['id']==557159][0]
router_feature.attributesroute_edit = router_feature
pt = Point({"x" : -111.93345, "y" : 33.59674,
"spatialReference" : {"wkid" : 4326}})router_feature.geometry = pt
display(route_edit)
update_result = router_flayer.edit_features(updates=[route_edit])
update_result
Thanks for any help
Mele
Solved! Go to Solution.
I found a solution router_feature = [f for f in router_features if f.attributes['id']== + id][0]
pt = Point({"x" : longitude, "y" : latitude,
"spatialReference" : {"wkid" : 4326}})
I found a solution router_feature = [f for f in router_features if f.attributes['id']== + id][0]
pt = Point({"x" : longitude, "y" : latitude,
"spatialReference" : {"wkid" : 4326}})