<?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: Error on Centroid from Polygon script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575801#M45120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is exactly what I did to look for them! &amp;nbsp;Great advice!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 May 2017 16:11:41 GMT</pubDate>
    <dc:creator>MosquitoGIS</dc:creator>
    <dc:date>2017-05-05T16:11:41Z</dc:date>
    <item>
      <title>Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575791#M45110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, for the record, I don't know jack about Python! &amp;nbsp;And I am pretty sure this is a pretty basic question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create Centroids from polygon features. &amp;nbsp;I found some code that does this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;input_fc = "N:\\GeoDatabase.gdb\\SpotHistory"&lt;BR /&gt;output_fc = "\\\\SERVER\\Send\\CentroidHist"&lt;/P&gt;&lt;P&gt;cursor = arcpy.da.SearchCursor(input_fc, "SHAPE@XY")&lt;BR /&gt;centroid_coords = []&lt;BR /&gt;for feature in cursor:&lt;BR /&gt; centroid_coords.append(feature[0])&lt;/P&gt;&lt;P&gt;point = arcpy.Point()&lt;BR /&gt;pointGeometryList = []&lt;/P&gt;&lt;P&gt;for pt in centroid_coords:&lt;BR /&gt; point.X = pt[0]&lt;BR /&gt; point.Y = pt[1]&lt;/P&gt;&lt;P&gt;pointGeometry = arcpy.PointGeometry(point)&lt;BR /&gt; pointGeometryList.append(pointGeometry)&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(pointGeometryList, output_fc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The issue is it works on most of my polygon features no problem. &amp;nbsp;But on another, I get the following error:&lt;BR /&gt;&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "N:/Script.py", line 16 in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; point.X = pt[0]&lt;BR /&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\arcobjets\_base.py", line 89, in _set&lt;BR /&gt;&amp;nbsp; return setattr(self._arc_object, attr_name, cval(val))&lt;BR /&gt;RuntimeError: Point: Input value is not numeric&lt;BR /&gt;&lt;BR /&gt;What do I need to do to fix this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 20:09:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575791#M45110</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-04T20:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575792#M45111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd recommend adding a print statement to see what value pt[0] and pt[1]is pulling for each point.&amp;nbsp; The error is clearly receiving a non-numeric value which is causing it to crash(maybe a NaN, have you tried to check the geometry for errors or repair it?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for pt in centroid_coords:&lt;BR /&gt; point.X = pt[0]&lt;BR /&gt; point.Y = pt[1]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for pt in centroid_coords:&lt;BR /&gt;print str(pt[0])&lt;BR /&gt;print str(pt[1])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should print to your screen each pair of values, and you should be able to determine which is a non-numeric value.&amp;nbsp; I hope your polygon dataset isn't to big&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 20:20:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575792#M45111</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-05-04T20:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575793#M45112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the print out gives me all coordinates except for one set of "None." &amp;nbsp;I am going to look through the features. &amp;nbsp;Any tips on what would cause a none?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 21:01:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575793#M45112</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-04T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575794#M45113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Devin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's probably a feature with "Null Geometry". It's technically a feature in your feature class (and a row in the attribute table) but an empty value for the SHAPE field, which in Python-speak is represented by the None keyword. So, you could delete that feature or create a shape for it. Use the Check Geometry or Repair Geometry tools to find and correct that feature and any others like it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side note, are you familiar with the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature-to-point.htm"&gt;Feature to Point&lt;/A&gt; tool? It'll get you polygon centroids nice and easy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 21:25:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575794#M45113</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-05-04T21:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575795#M45114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Makes sense, found the culprit. &amp;nbsp;I am familiar with that tool, however when I go to use it, it says I am not authorized to use that tool. &amp;nbsp;We only use ArcGIS Basic with no extensions, so we are a limited.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 21:32:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575795#M45114</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-04T21:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575796#M45115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would run the check geometry and it will tell what the geometry problem is.&amp;nbsp; You can repair the geometry using the repair geometry tool on the input dataset.&amp;nbsp; You may wish to make a duplicate dataset to test the repair on first(not that it should cause an issue, but just in case as it does edit your existing dataset).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't directly run into reasons for bad geometries being created, but you can read this help on checking and repairing geometries that should take care of things.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/checking-and-repairing-geometries.htm"&gt;http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/checking-and-repairing-geometries.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 21:34:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575796#M45115</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-05-04T21:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575797#M45116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cool, man! Good for you for customizing your way out of that license level conundrum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 21:35:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575797#M45116</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-05-04T21:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575798#M45117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the OP is using the ArcPy Data Access cursors, it could either be an empty geometry or NULL.&amp;nbsp; Unlike the original ArcPy cursors, the Data Access cursors return all empty geometries as None, which is beyond lame in my opinion.&amp;nbsp; I discuss the topic in more detail in &lt;A href="https://community.esri.com/blogs/tilting/2015/05/29/whats-in-your-feature-class-nothing-null-or-empty"&gt;/blogs/tilting/2015/05/29/whats-in-your-feature-class-nothing-null-or-empty&lt;/A&gt;.&amp;nbsp; Fortunately for the OP, Check Geometry catches empty geometries and NULL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 00:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575798#M45117</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-05-05T00:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575799#M45118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or, if these are polygon geometries...&lt;/P&gt;&lt;P&gt;Open the attribute table and sort by shape_area. Those ones with area = 0, are likely to be null geometries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 08:02:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575799#M45118</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2017-05-05T08:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575800#M45119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is the idea! &amp;nbsp;So far, so good! &amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 16:11:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575800#M45119</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-05T16:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575801#M45120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is exactly what I did to look for them! &amp;nbsp;Great advice!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 16:11:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575801#M45120</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-05T16:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Error on Centroid from Polygon script</title>
      <link>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575802#M45121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks found a few other issues using the tools that I didn't even know I had!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 16:12:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-on-centroid-from-polygon-script/m-p/575802#M45121</guid>
      <dc:creator>MosquitoGIS</dc:creator>
      <dc:date>2017-05-05T16:12:20Z</dc:date>
    </item>
  </channel>
</rss>

