<?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: how to get area for each part of a multipart polygon using python (ArcGIS 9.3)? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213731#M16470</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll get more details in this topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Reading_geometries" rel="nofollow noopener noreferrer" target="_blank"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Reading_geometries&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my modified version of the sample in the above topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)

infc = "path to input features"

dsc = gp.Describe(infc)
shapefieldname = dsc.ShapeFieldName

rows = gp.SearchCursor(infc)
row = rows.Next()

while row:

&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; partcount = feat.PartCount

&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through each part of a multipart feature
&amp;nbsp;&amp;nbsp;&amp;nbsp; while partnum &amp;lt; partcount:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poly = feat.GetPart(partnum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poly_area = poly.Area
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()

del row
del rows
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is not tested thoroughly - you may need to edit if you find any error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:29:04 GMT</pubDate>
    <dc:creator>NobbirAhmed</dc:creator>
    <dc:date>2021-12-11T10:29:04Z</dc:date>
    <item>
      <title>how to get area for each part of a multipart polygon using python (ArcGIS 9.3)?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213730#M16469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Russel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 20:46:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213730#M16469</guid>
      <dc:creator>ducksunlimited</dc:creator>
      <dc:date>2012-06-12T20:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to get area for each part of a multipart polygon using python (ArcGIS 9.3)?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213731#M16470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll get more details in this topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Reading_geometries" rel="nofollow noopener noreferrer" target="_blank"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Reading_geometries&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my modified version of the sample in the above topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)

infc = "path to input features"

dsc = gp.Describe(infc)
shapefieldname = dsc.ShapeFieldName

rows = gp.SearchCursor(infc)
row = rows.Next()

while row:

&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; partcount = feat.PartCount

&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through each part of a multipart feature
&amp;nbsp;&amp;nbsp;&amp;nbsp; while partnum &amp;lt; partcount:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poly = feat.GetPart(partnum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poly_area = poly.Area
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()

del row
del rows
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is not tested thoroughly - you may need to edit if you find any error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213731#M16470</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2021-12-11T10:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to get area for each part of a multipart polygon using python (ArcGIS 9.3)?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213732#M16471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm afraid it's not so easy. The &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;GetPart() &lt;/SPAN&gt;&lt;SPAN&gt;method returns &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Array &lt;/SPAN&gt;&lt;SPAN&gt;object not &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Geometry&lt;/SPAN&gt;&lt;SPAN&gt;. And &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Array &lt;/SPAN&gt;&lt;SPAN&gt;doesn't have &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Area &lt;/SPAN&gt;&lt;SPAN&gt;property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't find easy way to convert back Array to Geometry without using cursors, so I suggest using GP tool &lt;/SPAN&gt;&lt;A href="http://webhelp.esri.com/arcgiSDEsktop/9.3/index.cfm?TopicName=Multipart_to_Singlepart_%28Data_Management%29" rel="nofollow noopener noreferrer" target="_blank"&gt;Multipart to Singlepart (Data Management)&lt;/A&gt;&lt;SPAN&gt; and then calculate area for each single polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to report which multipart polygons were exploder, look at script example in web help for this tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the script which uses this tool, writes singlepart feature class to memory (not to disk) and calculates area:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)

infc = r"Z:\Test.gdb\MultipartPolygon"
singlePartFC = r"in_memory\SinglePart"
gp.MultipartToSinglepart_management(infc,singlePartFC)

dsc = gp.Describe(singlePartFC)
shapefieldname = dsc.ShapeFieldName

rows = gp.SearchCursor(singlePartFC)
row = rows.Next()

while row:
 feat = row.getValue(shapefieldname)
 poly_area = feat.Area
 print poly_area

 row = rows.Next()

del row, rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213732#M16471</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2021-12-11T10:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to get area for each part of a multipart polygon using python (ArcGIS 9.3)?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213733#M16472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What a challenge to an old school surveyor's assistant!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An array of coordinate pairs is what we always had after reducing a traverse, when we had to calculate the parcel area.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This was hard to do with only an adding machine and 10 figure log book. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hence the Double Difference Area method: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Consider each segment is a trapezoid above the X axis.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The area is half times the average of the Y of each side times the difference of the X values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sum these areas and that is the net area.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wait until the end to halve the Y values once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you go around the polygon, coming in reverse has negative values under the polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not quite sure why Esri gets a different result (1 in a million), must be the round off of the precision.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# area of multiparts
import arcgisscripting
gp = arcgisscripting.create(9.3)

infc = "C:/path.gdb/multipolyfc"

dsc = gp.Describe(infc)
shapefieldname = dsc.ShapeFieldName

rows = gp.SearchCursor(infc) #,"multipart&amp;nbsp; = 2")
row = rows.Next()

while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; partcount = feat.PartCount
&amp;nbsp;&amp;nbsp;&amp;nbsp; partArea = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; cumArea = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; print partcount ,feat.area
&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through each part of a multipart feature
&amp;nbsp;&amp;nbsp;&amp;nbsp; while partnum &amp;lt; partcount:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayPoly = feat.GetPart(partnum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through each vertex of the array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # use old pre-computer Double Difference Area survey trick
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = arrayPoly.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x0 = pt.x
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y0 = pt.y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = arrayPoly.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partArea = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while pt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partArea += (pt.x - x0) * (pt.y + y0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x0 = pt.x
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y0 = pt.y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = arrayPoly.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partArea = partArea / 2.0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print partnum,partArea
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cumArea += partArea
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "count %d,cum %f, feat %f diff (%12.8f) " % (partcount, cumArea,feat.area ,(feat.area - cumArea)/100)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # break&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()
del row
del rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-area-for-each-part-of-a-multipart/m-p/213733#M16472</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T10:29:10Z</dc:date>
    </item>
  </channel>
</rss>

