Select to view content in your preferred language

Overwrite in find_centroids not working?

118
0
12-06-2024 03:37 PM
LDoty
by
Emerging Contributor

I have a feature layer with 163 line features.  I ran find_centroids() to generate a centroid feature layer (which appears to be working based on the credit usage.)  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.)  What am I missing?

from arcgis import features
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.features import FeatureLayerCollection
from arcgis.features.analysis import find_centroids

# VERIFY FEATURE COUNT IN Infrastructure Projects (Lines)
ipLayer_id = gis.content.get("67...5")
ipLines_id_count = ipLayer_id.layers[1].query()
print(
     f"Infrastructure Projects (Lines) has {len(ipLines_id_count.features)} features."
)
#RESULT: Infrastructure Projects (Lines) has 163 features.

# FIND CENTROIDS OF Infrastructure Projects (Lines)
ipLines_url = {"url": "https://services.../FeatureServer/2"}
centroid_results = find_centroids(
     input_layer=ipLines_url,
     point_location=False,
     output_name={
          "serviceProperties": {
               "name": "InfrastructureProjectCentroids"
          },
          "itemProperties": {
               "itemId": "11...2",
               "overwrite": True
          }
     }
)
#RESULT: {"cost": 0.163}

# VERIFY FEATURE COUNT IN InfrastructureProjectsCentroids
ipCentroids_id = gis.content.get("11...2")
ipCentroids_id_count = ipCentroids_id.layers[0].query()
print(
     f"InfrastructureProjectsCentroids has {len(ipCentroids_id_count.features)} features."
)
#RESULT: InfrastructureProjectsCentroids has 0 features.

0 Kudos
0 Replies