<?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: Calculating rectangular extends for polygon grids in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678244#M52574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when i tried to give the field calculator expression in Quantum GIS it is throwing error like "An error occured while evaluating the calculation string"..Please provide me solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vamshi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Wade,&lt;BR /&gt;&lt;BR /&gt;one way you could go is with field calculator:&lt;BR /&gt;1. create fields for centroidX/centroidY of the grids, calculate geometry for them.&lt;BR /&gt;2. create fields for UpperY, LowerY, LeftX, RightX&lt;BR /&gt;&lt;BR /&gt;in field calculator you can then calculate each field:&lt;BR /&gt;UpperY = centroidY + (gridheight*0.5)&lt;BR /&gt;LowerY = centroidY - (gridheight*0.5)&lt;BR /&gt;LeftX = centroidX - (gridwidth*0.5)&lt;BR /&gt;RightX = centroidX + (gridwidth*0.5)&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Mar 2012 05:53:19 GMT</pubDate>
    <dc:creator>VAMSHIKRISHNA</dc:creator>
    <dc:date>2012-03-30T05:53:19Z</dc:date>
    <item>
      <title>Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678237#M52567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking for a little from the guru's out there on a task I'm trying to accomplish.&amp;nbsp; I have a vector file I created using the fishnet tool that consists of hundreds of rectagular "grids".&amp;nbsp; I'd like to loop through the records and find the uuper and lower Y, and left and right X values for each grid and write them to the appropriate new columns in the dataset (UpperY, LowerY, LeftX, RightX)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on how to go about doing this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 14:49:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678237#M52567</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2012-03-15T14:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678238#M52568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm... You can get X and Y coordinates of the rectangle centroid from Calculate Geometry (right-click column, choose Calculate Geometry). You can get width and height value from the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Minimum_Bounding_Geometry/00170000003q000000/"&gt;Minimum Bounding Geometry &lt;/A&gt;&lt;SPAN&gt;tool (group by Object ID, envelope shape). Join output back to fishnet. Then, you should be able to subtract or add half the width and height to get your desired values. Warning: totally untested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: I just realized this is in the Python forum. I guarantee there is a Python solution, not that I know it off hand. Check out &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Reading_geometries/002z0000001t000000/"&gt;Reading Geometry&lt;/A&gt;&lt;SPAN&gt;. Also, looks relatively simple to get to an &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Extent/000v0000006r000000/"&gt;Extent &lt;/A&gt;&lt;SPAN&gt;object which has the values you're looking for (see the example).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 15:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678238#M52568</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-03-15T15:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678239#M52569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is an example that may help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;fc = "fishnet"&amp;nbsp; rows = arcpy.UpdateCursor(fc) for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.shape &amp;nbsp;&amp;nbsp;&amp;nbsp; row.LowerX = geom.extent.XMin &amp;nbsp;&amp;nbsp;&amp;nbsp; row.UpperX = geom.extent.XMax &amp;nbsp;&amp;nbsp;&amp;nbsp; row.LowerY = geom.extent.YMin &amp;nbsp;&amp;nbsp;&amp;nbsp; row.UpperY = geom.extent.YMax &amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&amp;nbsp; del row, rows &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 15:43:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678239#M52569</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-03-15T15:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678240#M52570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wade,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;one way you could go is with field calculator:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. create fields for centroidX/centroidY of the grids, calculate geometry for them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. create fields for UpperY, LowerY, LeftX, RightX&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in field calculator you can then calculate each field:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;UpperY = centroidY + (gridheight*0.5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LowerY = centroidY - (gridheight*0.5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LeftX = centroidX - (gridwidth*0.5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RightX = centroidX + (gridwidth*0.5)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 15:45:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678240#M52570</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2012-03-15T15:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678241#M52571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Wade,&lt;BR /&gt;&lt;BR /&gt;one way you could go is with field calculator:&lt;BR /&gt;1. create fields for centroidX/centroidY of the grids, calculate geometry for them.&lt;BR /&gt;2. create fields for UpperY, LowerY, LeftX, RightX&lt;BR /&gt;&lt;BR /&gt;in field calculator you can then calculate each field:&lt;BR /&gt;UpperY = centroidY + (gridheight*0.5)&lt;BR /&gt;LowerY = centroidY - (gridheight*0.5)&lt;BR /&gt;LeftX = centroidX - (gridwidth*0.5)&lt;BR /&gt;RightX = centroidX + (gridwidth*0.5)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thought about doing something similar to this after the first reply, but a little worried as to what the results would be if I want them in decimal degrees.&amp;nbsp; Going to try the python code above first after my computer finishes up its processing task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 15:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678241#M52571</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2012-03-15T15:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678242#M52572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Going to try the python code above&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;that´s what i´d do too (if i had known it was that straight forward, thanks Jake!) &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 16:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678242#M52572</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2012-03-15T16:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678243#M52573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Here is an example that may help:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fc = "fishnet"

rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.LowerX = geom.extent.XMin
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.UpperX = geom.extent.XMax
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.LowerY = geom.extent.YMin
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.UpperY = geom.extent.YMax
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del row, rows &lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch!&amp;nbsp; Worked like a charm!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678243#M52573</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2021-12-12T04:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rectangular extends for polygon grids</title>
      <link>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678244#M52574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when i tried to give the field calculator expression in Quantum GIS it is throwing error like "An error occured while evaluating the calculation string"..Please provide me solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vamshi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Wade,&lt;BR /&gt;&lt;BR /&gt;one way you could go is with field calculator:&lt;BR /&gt;1. create fields for centroidX/centroidY of the grids, calculate geometry for them.&lt;BR /&gt;2. create fields for UpperY, LowerY, LeftX, RightX&lt;BR /&gt;&lt;BR /&gt;in field calculator you can then calculate each field:&lt;BR /&gt;UpperY = centroidY + (gridheight*0.5)&lt;BR /&gt;LowerY = centroidY - (gridheight*0.5)&lt;BR /&gt;LeftX = centroidX - (gridwidth*0.5)&lt;BR /&gt;RightX = centroidX + (gridwidth*0.5)&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 05:53:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-rectangular-extends-for-polygon-grids/m-p/678244#M52574</guid>
      <dc:creator>VAMSHIKRISHNA</dc:creator>
      <dc:date>2012-03-30T05:53:19Z</dc:date>
    </item>
  </channel>
</rss>

