<?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 Re: What is the recommended method to overwrite feature layer data using Python API? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1515203#M10404</link>
    <description>&lt;P&gt;I have it working from a file gdb at the very least. So far so good. Thank you for this insight. It's a life saver!&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2024 22:01:46 GMT</pubDate>
    <dc:creator>LRoberts_RDM</dc:creator>
    <dc:date>2024-08-05T22:01:46Z</dc:date>
    <item>
      <title>What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372156#M9546</link>
      <description>&lt;P&gt;I have a feature layer that I'm trying to update regularly with new data using the ArcGIS Online Python API.&lt;/P&gt;&lt;P&gt;The two methods I've found in ESRI docs are to create a featurelayer collection and use overwrite() or to use the Truncate and Append method.&lt;/P&gt;&lt;P&gt;The overwwrite() method doesn't change any of the data but says the operation is successful, so there's no indication why it hasn't worked.&lt;/P&gt;&lt;P&gt;The truncate and append method fails at calling append() with an unspecified 500 error.&lt;/P&gt;&lt;P&gt;I would love to know what the officially supported way to overwrite an existing layer on AGOL is, either from a spatially-enabled data frame or from a layer in a file geodatabase.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 10:15:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372156#M9546</guid>
      <dc:creator>A_Schwab</dc:creator>
      <dc:date>2024-01-19T10:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372221#M9547</link>
      <description>&lt;P&gt;Truncate and append is the method to use. Overwriting a feature service has historically led to problems.&lt;/P&gt;&lt;P&gt;Don't use the literal append() method, either. If you've got a spatial dataframe, you can just do&lt;/P&gt;&lt;PRE&gt;FeatureLayer.edit_features(adds=spatial_dataframe.spatial.to_featureset())&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2024 14:11:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372221#M9547</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-01-19T14:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372296#M9548</link>
      <description>&lt;P&gt;Looks like `edit_features()` does what I need so I'll go ahead with that. Thanks for the info!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 15:48:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1372296#M9548</guid>
      <dc:creator>A_Schwab</dc:creator>
      <dc:date>2024-01-19T15:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1513963#M10395</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;, I am currently losing my mind to this issue. I'm curious if you have a workflow for getting data into a spatial dataframe? Currently I am exporting data from enterprise gdb to a file gdb, zipping that up and pushing to AGOL, then using FeatureLayer.append() to update my hosted feature service. I'm having wildly inconsistent succes/fails with the append portion. Sometimes it works, and other times it returns "Unknown Error (Error Code: 500).&lt;BR /&gt;&lt;BR /&gt;Will the spatial data frame work if I have 90,000 polygons I need to push into a hosted feature service?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 23:37:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1513963#M10395</guid>
      <dc:creator>LRoberts_RDM</dc:creator>
      <dc:date>2024-08-01T23:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1514132#M10398</link>
      <description>&lt;P&gt;I put a generic version of the process in this repo:&lt;/P&gt;&lt;P&gt;&lt;A href="https://codeberg.org/kendall-county-gis/project-templates/src/branch/main/generic-etl" target="_blank"&gt;https://codeberg.org/kendall-county-gis/project-templates/src/branch/main/generic-etl&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To pull your stuff from an EGDB, you might want to look at pandas.read_sql() in conjunction with arcgis.features.GeoAccessor.from_df(). I've never used it to query an EGDB directly, so maybe there's a method in the arcgis Python API to do so more directly?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 12:26:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1514132#M10398</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-08-02T12:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1515203#M10404</link>
      <description>&lt;P&gt;I have it working from a file gdb at the very least. So far so good. Thank you for this insight. It's a life saver!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 22:01:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1515203#M10404</guid>
      <dc:creator>LRoberts_RDM</dc:creator>
      <dc:date>2024-08-05T22:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1520634#M10424</link>
      <description>&lt;P&gt;Just a quick follow up note regarding this thread. I ran into issues using the edit_features(adds=featureset) because my feature set was too large (approx 80,000 polygons). I was able to make the overwrite work using the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;output_zip = [path to zip]
gis = GIS("https://www.arcgis.com", username, password)
item = gis.content.get([item id])
flc = FeatureLayerCollection.fromitem(item)

flc.manager.overwrite(output_zip)&lt;/LI-CODE&gt;&lt;P&gt;One very important note that I should add is that at first, I was using the shutil python library to zip my file geodatabase. I would get an error during the overwrite. I changed that to the zipfile library, and it worked like a champ.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 16:00:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1520634#M10424</guid>
      <dc:creator>LRoberts_RDM</dc:creator>
      <dc:date>2024-08-13T16:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended method to overwrite feature layer data using Python API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1520649#M10425</link>
      <description>&lt;P&gt;With that many, you'll want to batch the updates.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;i = 0
batchsize = 200

while i &amp;lt; len(df):
    batch = df.iloc[i:i+batchsize]
    fl.edit_features(adds=df.spatial.to_featureset())
    i += batchsize&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 16:05:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/what-is-the-recommended-method-to-overwrite/m-p/1520649#M10425</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-08-13T16:05:13Z</dc:date>
    </item>
  </channel>
</rss>

