<?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: Overwrite in find_centroids not working? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-in-find-centroids-not-working/m-p/1578578#M11084</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/426027"&gt;@Mountain_Mapper&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You just need to clean-up the syntax a bit. See below...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## the first run, creating the point feature layer with the centroids

centroid_results = find_centroids(
     input_layer=ipLines_url,
     point_location=False,
     output_name= "InfrastructureProjectCentroids"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you have your point feature layer created from the you can re-use it and overwrite.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## any run after the initial creation of the point feature layer

centroid_item = agol.content.get("FS_ITEM_ID")
centroid_fl = centroid_item.layers[0]

centroid_results = find_centroids(
     input_layer=ipLines_url,
     point_location=False,
     output_name= centroid_fl,
     context = {
         "overwrite": True
     }
)&lt;/LI-CODE&gt;&lt;P&gt;I hope that helps,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2025 10:24:17 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2025-01-24T10:24:17Z</dc:date>
    <item>
      <title>Overwrite in find_centroids not working?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-in-find-centroids-not-working/m-p/1565886#M11083</link>
      <description>&lt;P&gt;I have a feature layer with 163 line features.&amp;nbsp; I ran find_centroids() to generate a centroid feature layer (which appears to be working based on the credit usage.)&amp;nbsp; I'd like to overwrite that centroid layer each time the script runs but the resulting feature layer shows no features. (I previously removed the features in the centroid layer to test the overwrite function.)&amp;nbsp; What am I missing?&lt;/P&gt;&lt;P&gt;from arcgis import features&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;from arcgis.features import FeatureLayerCollection&lt;BR /&gt;from arcgis.features.analysis import find_centroids&lt;/P&gt;&lt;P&gt;# VERIFY FEATURE COUNT IN Infrastructure Projects (Lines)&lt;BR /&gt;ipLayer_id = gis.content.get("67...5")&lt;BR /&gt;ipLines_id_count = ipLayer_id.layers[1].query()&lt;BR /&gt;print(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;f"Infrastructure Projects (Lines) has {len(ipLines_id_count.features)} features."&lt;BR /&gt;)&lt;BR /&gt;#RESULT: Infrastructure Projects (Lines) has &lt;STRONG&gt;163 features&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;# FIND CENTROIDS OF Infrastructure Projects (Lines)&lt;BR /&gt;ipLines_url = {"url": "&lt;A href="https://services.../FeatureServer/2" target="_blank"&gt;https://services.../FeatureServer/2&lt;/A&gt;"}&lt;BR /&gt;centroid_results = find_centroids(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input_layer=ipLines_url,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;point_location=False,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;output_name={&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "serviceProperties": {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"name": "InfrastructureProjectCentroids"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "itemProperties": {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"itemId": "11...2",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"overwrite": True&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;)&lt;BR /&gt;#RESULT: {&lt;STRONG&gt;"cost": 0.163&lt;/STRONG&gt;}&lt;/P&gt;&lt;P&gt;# VERIFY FEATURE COUNT IN InfrastructureProjectsCentroids&lt;BR /&gt;ipCentroids_id = gis.content.get("11...2")&lt;BR /&gt;ipCentroids_id_count = ipCentroids_id.layers[0].query()&lt;BR /&gt;print(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;f"InfrastructureProjectsCentroids has {len(ipCentroids_id_count.features)} features."&lt;BR /&gt;)&lt;BR /&gt;#RESULT: InfrastructureProjectsCentroids has &lt;STRONG&gt;0 features&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 23:37:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-in-find-centroids-not-working/m-p/1565886#M11083</guid>
      <dc:creator>Mountain_Mapper</dc:creator>
      <dc:date>2024-12-06T23:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite in find_centroids not working?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-in-find-centroids-not-working/m-p/1578578#M11084</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/426027"&gt;@Mountain_Mapper&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You just need to clean-up the syntax a bit. See below...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## the first run, creating the point feature layer with the centroids

centroid_results = find_centroids(
     input_layer=ipLines_url,
     point_location=False,
     output_name= "InfrastructureProjectCentroids"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you have your point feature layer created from the you can re-use it and overwrite.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;## any run after the initial creation of the point feature layer

centroid_item = agol.content.get("FS_ITEM_ID")
centroid_fl = centroid_item.layers[0]

centroid_results = find_centroids(
     input_layer=ipLines_url,
     point_location=False,
     output_name= centroid_fl,
     context = {
         "overwrite": True
     }
)&lt;/LI-CODE&gt;&lt;P&gt;I hope that helps,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 10:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-in-find-centroids-not-working/m-p/1578578#M11084</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-01-24T10:24:17Z</dc:date>
    </item>
  </channel>
</rss>

