<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Passing a variable in Python to Update Feature in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/passing-a-variable-in-python-to-update-feature/m-p/1116540#M62972</link>
    <description>&lt;P&gt;I am trying to update features in an AGOL feature layer&amp;nbsp; in Python.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looping through some Json returning routers and then want to update the feature that matches the router ID&lt;/P&gt;&lt;P&gt;The example works below, but I can't figure out how to change&amp;nbsp;&amp;nbsp;router_feature = [f for f in router_features if f.attributes['id']==557159][0] to use a variable.&lt;/P&gt;&lt;P&gt;In the same vein,&amp;nbsp; &amp;nbsp;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&lt;/P&gt;&lt;P&gt;pt = Point({"x" : -111.93345, "y" : 33.59674,&lt;BR /&gt;"spatialReference" : {"wkid" : 4326}})&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search_result = gis.content.search('title:my Routers')&lt;BR /&gt;router_item = search_result[0]&lt;BR /&gt;search_result[0]&lt;/P&gt;&lt;P&gt;router_item = search_result[0]&lt;BR /&gt;print (router_item)&lt;BR /&gt;router_layers = router_item.layers&lt;BR /&gt;router_layers&lt;/P&gt;&lt;P&gt;router_fset = router_layers[0].query()&lt;/P&gt;&lt;P&gt;router_features = router_fset.features&lt;/P&gt;&lt;P&gt;router_flayer = router_layers[0]&lt;BR /&gt;router_flayer.properties.capabilities&lt;/P&gt;&lt;P&gt;router_feature = [f for f in router_features if f.attributes['id']==557159][0]&lt;BR /&gt;router_feature.attributes&lt;/P&gt;&lt;P&gt;route_edit = router_feature&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pt = Point({"x" : -111.93345, "y" : 33.59674,&lt;BR /&gt;"spatialReference" : {"wkid" : 4326}})&lt;/P&gt;&lt;P&gt;router_feature.geometry = pt&lt;/P&gt;&lt;P&gt;display(route_edit)&lt;BR /&gt;update_result = router_flayer.edit_features(updates=[route_edit])&lt;BR /&gt;update_result&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;Thanks for any help&lt;/P&gt;&lt;P&gt;Mele&lt;/P&gt;</description>
    <pubDate>Fri, 12 Nov 2021 23:33:37 GMT</pubDate>
    <dc:creator>MeleKoneya</dc:creator>
    <dc:date>2021-11-12T23:33:37Z</dc:date>
    <item>
      <title>Passing a variable in Python to Update Feature</title>
      <link>https://community.esri.com/t5/python-questions/passing-a-variable-in-python-to-update-feature/m-p/1116540#M62972</link>
      <description>&lt;P&gt;I am trying to update features in an AGOL feature layer&amp;nbsp; in Python.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looping through some Json returning routers and then want to update the feature that matches the router ID&lt;/P&gt;&lt;P&gt;The example works below, but I can't figure out how to change&amp;nbsp;&amp;nbsp;router_feature = [f for f in router_features if f.attributes['id']==557159][0] to use a variable.&lt;/P&gt;&lt;P&gt;In the same vein,&amp;nbsp; &amp;nbsp;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&lt;/P&gt;&lt;P&gt;pt = Point({"x" : -111.93345, "y" : 33.59674,&lt;BR /&gt;"spatialReference" : {"wkid" : 4326}})&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search_result = gis.content.search('title:my Routers')&lt;BR /&gt;router_item = search_result[0]&lt;BR /&gt;search_result[0]&lt;/P&gt;&lt;P&gt;router_item = search_result[0]&lt;BR /&gt;print (router_item)&lt;BR /&gt;router_layers = router_item.layers&lt;BR /&gt;router_layers&lt;/P&gt;&lt;P&gt;router_fset = router_layers[0].query()&lt;/P&gt;&lt;P&gt;router_features = router_fset.features&lt;/P&gt;&lt;P&gt;router_flayer = router_layers[0]&lt;BR /&gt;router_flayer.properties.capabilities&lt;/P&gt;&lt;P&gt;router_feature = [f for f in router_features if f.attributes['id']==557159][0]&lt;BR /&gt;router_feature.attributes&lt;/P&gt;&lt;P&gt;route_edit = router_feature&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pt = Point({"x" : -111.93345, "y" : 33.59674,&lt;BR /&gt;"spatialReference" : {"wkid" : 4326}})&lt;/P&gt;&lt;P&gt;router_feature.geometry = pt&lt;/P&gt;&lt;P&gt;display(route_edit)&lt;BR /&gt;update_result = router_flayer.edit_features(updates=[route_edit])&lt;BR /&gt;update_result&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;Thanks for any help&lt;/P&gt;&lt;P&gt;Mele&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 23:33:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-a-variable-in-python-to-update-feature/m-p/1116540#M62972</guid>
      <dc:creator>MeleKoneya</dc:creator>
      <dc:date>2021-11-12T23:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable in Python to Update Feature</title>
      <link>https://community.esri.com/t5/python-questions/passing-a-variable-in-python-to-update-feature/m-p/1116660#M62978</link>
      <description>&lt;P&gt;I found a solution&amp;nbsp;router_feature = [f for f in router_features if f.attributes['id']== + id][0]&lt;/P&gt;&lt;P&gt;pt = Point({"x" : longitude, "y" : latitude,&lt;BR /&gt;"spatialReference" : {"wkid" : 4326}})&lt;/P&gt;</description>
      <pubDate>Sun, 14 Nov 2021 15:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-a-variable-in-python-to-update-feature/m-p/1116660#M62978</guid>
      <dc:creator>MeleKoneya</dc:creator>
      <dc:date>2021-11-14T15:03:48Z</dc:date>
    </item>
  </channel>
</rss>

