So, for the record, I don't know jack about Python! And I am pretty sure this is a pretty basic question.
I want to create Centroids from polygon features. I found some code that does this:
import arcpy
arcpy.env.overwriteOutput = True
input_fc = "N:\\GeoDatabase.gdb\\SpotHistory"
output_fc = "\\\\SERVER\\Send\\CentroidHist"
cursor = arcpy.da.SearchCursor(input_fc, "SHAPE@XY")
centroid_coords = []
for feature in cursor:
centroid_coords.append(feature[0])
point = arcpy.Point()
pointGeometryList = []
for pt in centroid_coords:
point.X = pt[0]
point.Y = pt[1]
pointGeometry = arcpy.PointGeometry(point)
pointGeometryList.append(pointGeometry)
arcpy.CopyFeatures_management(pointGeometryList, output_fc)
The issue is it works on most of my polygon features no problem. But on another, I get the following error:
Traceback (most recent call last):
File "N:/Script.py", line 16 in <module>
point.X = pt[0]
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\arcobjets\_base.py", line 89, in _set
return setattr(self._arc_object, attr_name, cval(val))
RuntimeError: Point: Input value is not numeric
What do I need to do to fix this?