<?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: Polygon Centroid: Center of gravity &amp; Inner Centroid in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/polygon-centroid-center-of-gravity-inner-centroid/m-p/530054#M41499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good catch..but I hate it that the 'magic' is hidden.&amp;nbsp; Now can you determine the median as a representation of the centrality of a polygon (leave holes out of it for now) &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Apr 2016 22:07:52 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-04-18T22:07:52Z</dc:date>
    <item>
      <title>Polygon Centroid: Center of gravity &amp; Inner Centroid</title>
      <link>https://community.esri.com/t5/python-questions/polygon-centroid-center-of-gravity-inner-centroid/m-p/530053#M41498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I'd share the following with the community:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
Created on Apr 18, 2016


Centroid


of Polygon


@author: PeterW
'''
import arcpy
from arcpy.arcobjects.geometries import PointGeometry


input_fc = r"E:\Proposals\2016\what3words\Calcs.gdb\ftr_dwellings_zola_tm19"
output_fc = r"E:\Proposals\2016\what3words\Calcs.gdb\Centroids_Test15"




def coord_sys(input_fc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; projection = arcpy.Describe(input_fc).spatialReference
&amp;nbsp;&amp;nbsp;&amp;nbsp; return projection


projection = coord_sys(input_fc)




def centroid(input_fc, output_fc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(input_fc, "SHAPE@XY") as scur:&amp;nbsp; # @UndefinedVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; centroid_coords = []
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in scur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; centroid_coords.append(feature[0])


&amp;nbsp;&amp;nbsp;&amp;nbsp; point = arcpy.Point()
&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeometryList = []


&amp;nbsp;&amp;nbsp;&amp;nbsp; for pt in centroid_coords:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point.X = pt[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point.Y = pt[1]


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeometry = arcpy.PointGeometry(point, projection)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeometryList.append(pointGeometry)


&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(pointGeometryList, output_fc)


centroid(input_fc, output_fc)&lt;/PRE&gt;&lt;P&gt;Centroid: Center of Gravity&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
Created on Apr 18, 2016


Inner Centroid


of Polygon


@author: PeterW
'''
import arcpy


input_fc = r"E:\Proposals\2016\what3words\Calcs.gdb\ftr_dwellings_zola_tm19"
output_fc = r"E:\Proposals\2016\what3words\Calcs.gdb\Centroids_Test7"




def coord_sys(input_fc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; projection = arcpy.Describe(input_fc).spatialReference
&amp;nbsp;&amp;nbsp;&amp;nbsp; return projection


projection = coord_sys(input_fc)




def inner_centroid(input_fc, output_fc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; inner_centroid_geom = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(input_fc, "SHAPE@") as scur:&amp;nbsp; # @UndefinedVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for feature in scur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner_centroid_pnt = arcpy.PointGeometry(feature[0].labelPoint, projection)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner_centroid_geom.append(inner_centroid_pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(inner_centroid_geom, output_fc)


inner_centroid(input_fc, output_fc)&lt;/PRE&gt;&lt;P&gt;Centroid: Inner Centroid&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygon-centroid-center-of-gravity-inner-centroid/m-p/530053#M41498</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2021-12-11T23:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Polygon Centroid: Center of gravity &amp; Inner Centroid</title>
      <link>https://community.esri.com/t5/python-questions/polygon-centroid-center-of-gravity-inner-centroid/m-p/530054#M41499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good catch..but I hate it that the 'magic' is hidden.&amp;nbsp; Now can you determine the median as a representation of the centrality of a polygon (leave holes out of it for now) &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 22:07:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/polygon-centroid-center-of-gravity-inner-centroid/m-p/530054#M41499</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-18T22:07:52Z</dc:date>
    </item>
  </channel>
</rss>

