<?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 best way to update feature layer via spatial data frame? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855268#M3989</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to update a hosted feature layer after some manipulation on the data as a data frame. I am trying to follow the presentation here:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/" title="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/" rel="nofollow noopener noreferrer" target="_blank"&gt;updating_features_in_a_feature_layer | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a test, I have `update_layer` as a Spatial Data Frame object, but it is essentially the result of `flayer.query().df`, so, I was hoping this would overwrite the data in the feature layer, with the data in the feature layer, thus not actually changing anything but testing the overwrite operation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;flayer = search_result[0].layers[0] # this is the feature layer I want to update&lt;BR /&gt;print(flayer.properties.capabilities)&lt;/P&gt;&lt;P&gt;# get each row in the updated feature dataframe as a dictionary. store in a list.&lt;BR /&gt;features_for_update = [json.loads(row.to_json()) for index,row in update_layer.iterrows()]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# update should track by OID or whatever the default index is specified&lt;BR /&gt;flayer.edit_features(updates=features_for_update)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I receive this error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Cannot perform operation. Invalid operation parameters. 'updates' parameter is invalid Object reference not set to an instance of an object.

What is the correct representation of the items in `features_for_update`? The example in the link seems like it should be a list of dictionaries, which is what I have.


Cheers,
Joe&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:34:24 GMT</pubDate>
    <dc:creator>JoeMcGlinchy1</dc:creator>
    <dc:date>2021-12-12T10:34:24Z</dc:date>
    <item>
      <title>best way to update feature layer via spatial data frame?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855268#M3989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to update a hosted feature layer after some manipulation on the data as a data frame. I am trying to follow the presentation here:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/" title="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/" rel="nofollow noopener noreferrer" target="_blank"&gt;updating_features_in_a_feature_layer | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a test, I have `update_layer` as a Spatial Data Frame object, but it is essentially the result of `flayer.query().df`, so, I was hoping this would overwrite the data in the feature layer, with the data in the feature layer, thus not actually changing anything but testing the overwrite operation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;flayer = search_result[0].layers[0] # this is the feature layer I want to update&lt;BR /&gt;print(flayer.properties.capabilities)&lt;/P&gt;&lt;P&gt;# get each row in the updated feature dataframe as a dictionary. store in a list.&lt;BR /&gt;features_for_update = [json.loads(row.to_json()) for index,row in update_layer.iterrows()]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# update should track by OID or whatever the default index is specified&lt;BR /&gt;flayer.edit_features(updates=features_for_update)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I receive this error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Cannot perform operation. Invalid operation parameters. 'updates' parameter is invalid Object reference not set to an instance of an object.

What is the correct representation of the items in `features_for_update`? The example in the link seems like it should be a list of dictionaries, which is what I have.


Cheers,
Joe&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:34:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855268#M3989</guid>
      <dc:creator>JoeMcGlinchy1</dc:creator>
      <dc:date>2021-12-12T10:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: best way to update feature layer via spatial data frame?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855269#M3990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't run the code in jupyter, but I'd recommend trying a print statement of type(flayer) and&amp;nbsp; type(features_for_update).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'd recommend following the structure outlined &lt;A href="https://developers.arcgis.com/python/sample-notebooks/updating-features-in-a-feature-layer/#Updating-feature-layer-by-editing-individual-features"&gt;here&lt;/A&gt;&amp;nbsp;for updating hosted feature layers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2018 19:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855269#M3990</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-07-23T19:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: best way to update feature layer via spatial data frame?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855270#M3991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing you can look into is the SpatialDataFrame Object supports a to_featureset method.&lt;/P&gt;&lt;P&gt;That could be used as input to the edit_features method on the featurelayer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fs = MySpatDataFrame.to_featureset()&lt;BR /&gt;&lt;BR /&gt;flayer.edit_features(updates=fs)&lt;BR /&gt;&lt;BR /&gt;Take a look at the above and let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2018 21:23:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855270#M3991</guid>
      <dc:creator>JeffBigos</dc:creator>
      <dc:date>2018-07-23T21:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: best way to update feature layer via spatial data frame?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855271#M3992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jeff! This seems to do the trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2018 23:23:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/best-way-to-update-feature-layer-via-spatial-data/m-p/855271#M3992</guid>
      <dc:creator>JoeMcGlinchy1</dc:creator>
      <dc:date>2018-07-23T23:23:05Z</dc:date>
    </item>
  </channel>
</rss>

