<?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: Changing the centroid of a geometry object in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/changing-the-centroid-of-a-geometry-object/m-p/209722#M16230</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to do something similar to what you're doing, BUT I just need to create a point shapefile from the centroid of a grid index I already created. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to "copy" some of your example code in the python window, but the syntax error keeps popping up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess, you did this in PYTHON IDLE environment. But, does the parcel layer need to be existing. I'm using my existing grid I created, but the syntax is messing me up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Oct 2012 17:49:59 GMT</pubDate>
    <dc:creator>nimitz</dc:creator>
    <dc:date>2012-10-24T17:49:59Z</dc:date>
    <item>
      <title>Changing the centroid of a geometry object</title>
      <link>https://community.esri.com/t5/python-questions/changing-the-centroid-of-a-geometry-object/m-p/209721#M16229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Whats the easiest way to move one geometry to the center of another geometry? That attribute is read only. Im generating polygons and writing them out to a row in a script. Right now the first point of my geometry object is the centroid of a parcel which means the drawings intersect the correct parcel but are not centered on it. I just tried adding the difference between the parcel centroid and the geometry centroid but while that moved the new geometry it didnt move it to the centroid as &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had hoped. Below is what I tried, parcelLookup is a nested dictionary that has all of the parcel numbers with their centroids.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def addGeometry(inGeometry,parcelID,buildingNum,row): &amp;nbsp;&amp;nbsp;&amp;nbsp; diffX = (parcelLookup[parcelID]['x'] - arcpy.Geometry('polygon',inGeometry).centroid.X) &amp;nbsp;&amp;nbsp;&amp;nbsp; diffY = (parcelLookup[parcelID]['y'] - arcpy.Geometry('polygon',inGeometry).centroid.Y) &amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0,inGeometry.count): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldPoint = inGeometry.getObject(i) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPoint = arcpy.Point(oldPoint.X + diffX, oldPoint.Y + diffY) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inGeometry.replace(i,newPoint) &amp;nbsp;&amp;nbsp;&amp;nbsp; row.shape = arcpy.Geometry('polygon',inGeometry) &amp;nbsp;&amp;nbsp;&amp;nbsp; row.PID = parcelID &amp;nbsp;&amp;nbsp;&amp;nbsp; row.Id = buildingNum &amp;nbsp;&amp;nbsp;&amp;nbsp; rows.insertRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I was subtracting the centroid of the parcel from the centroid of the geometry. Thats backwards. Subtracting the geometry from the parcel is the right order. Cursed be all typos.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 13:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/changing-the-centroid-of-a-geometry-object/m-p/209721#M16229</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2012-10-08T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the centroid of a geometry object</title>
      <link>https://community.esri.com/t5/python-questions/changing-the-centroid-of-a-geometry-object/m-p/209722#M16230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to do something similar to what you're doing, BUT I just need to create a point shapefile from the centroid of a grid index I already created. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to "copy" some of your example code in the python window, but the syntax error keeps popping up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess, you did this in PYTHON IDLE environment. But, does the parcel layer need to be existing. I'm using my existing grid I created, but the syntax is messing me up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 17:49:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/changing-the-centroid-of-a-geometry-object/m-p/209722#M16230</guid>
      <dc:creator>nimitz</dc:creator>
      <dc:date>2012-10-24T17:49:59Z</dc:date>
    </item>
  </channel>
</rss>

