<?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 Mesuring Percentage of Feature Polygons that Overlap Each Other in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370540#M29291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to gather preliminary census data within a 15 minute walkshed and a 15 min bikeshed boundary that we have drawn around a development site.&amp;nbsp; As expected, neither of the "shed" layers fit perfectly into the Census Block Groups (CBGs) we have.&amp;nbsp; Now I know this is far from scientific, but we were thinking for the CBGs that only partially overlap the shed layers, calculate the percentage of the overlap, place that percentage in a field, and multiply statistics by that percentage.&amp;nbsp; I've been working on this script for over a week now and I simply cannot get it to work right.&amp;nbsp; Basically what I want it to do is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Create an Update Cursor in the CBGs layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Select each CBG polygon as it scrolls through&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Clip the "shed" layer to the selected polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Measure the shape area for the clipped layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Divide the area of the clipped layer by the CBG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Set the result as the value in the percentage field in CBG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Delete the clipped polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Repeat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;In its current form the script is completing without error, but with whole numbers that clearly are not the desired percentage.&amp;nbsp; Every time I try to create an AddMessage so that I can see what values are being divided I then get an error and am still unable to see where the values are coming.&amp;nbsp; This is the first time I've ever built a python script without step-by-step instructions so I'm very lost.&amp;nbsp; If anyone sees the errors in my code, any pointers would be greatly appreciated.&amp;nbsp; I have the script written below and have attached a zipped folder with the .py, the bikeshed, a few selected CBGs, and the toolbox I'm executing it with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;import arcpy&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;censuslayer = arcpy.GetParameter(0)#census unit layer&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;percentField = arcpy.GetParameter(1)#field where percentage will be input&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;studylayer = arcpy.GetParameter(2)#walk or bikeshed layer&lt;/SPAN&gt;



&lt;SPAN style="font-family: courier new,courier;"&gt;#currently unused#arcpy.AddField_management (censuslayer, "perc_cov", "float", "3", "3") #adds blank percentage field to census units&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;censussize = arcpy.AddField_management (censuslayer, "shapearea", "FLOAT")#adds shape area to census&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.CalculateField_management (censuslayer, "shapearea", "!shape.area@squarefeet!", "PYTHON") #calculates the geometry&lt;/SPAN&gt;


&lt;SPAN style="font-family: courier new,courier;"&gt;#for polygon in studylayer:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.AddField_management (studylayer, "shapearea", "FLOAT") #adds a shape area to walk or bikeshed&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#search = arcpy.SearchCursor(censuslayer)&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;update = arcpy.UpdateCursor(censuslayer)#creates update cursor to move through census layers&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;for row in update:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ceblocksize=float(row.getValue("shapearea"))#places shape area value in variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentCen=int(row.getValue("OBJECTID"))#places object ID field name in variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; holder=("in_memory\holder")#output&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause=str("'OBJECTID' = " + "'"+ str(currentCen)+"'")#formula to indicate record to select&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectBlock=arcpy.Select_analysis(censuslayer, holder, whereClause)#select record where cursor should be&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temppolygon = arcpy.Clip_analysis (studylayer, selectBlock, "templayer") #clip shape from shed layer to selected feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; studysize = arcpy.CalculateField_management (temppolygon, "shapearea", "!shape.area@squarefeet!", "PYTHON") #calculate geometry&amp;nbsp; of clipped feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; studysearch = arcpy.SearchCursor(temppolygon)# new cursor in clipped feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for only in studysearch:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shedsize = only.getValue("shapearea")#store the shape area in a variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.AddMessage(shedsize"/"ceblocksize)&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent = float(shedsize)/ceblocksize #get the value to place in new field&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(percentField, percent)#sets the value in field&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; update.updateRow(row)&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(temppolygon)#deletes the clipped polygon&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = update.next&lt;/SPAN&gt;


&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; Edit: Formatted Code Block &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:10:30 GMT</pubDate>
    <dc:creator>DanielInterrante1</dc:creator>
    <dc:date>2021-12-11T17:10:30Z</dc:date>
    <item>
      <title>Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370540#M29291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to gather preliminary census data within a 15 minute walkshed and a 15 min bikeshed boundary that we have drawn around a development site.&amp;nbsp; As expected, neither of the "shed" layers fit perfectly into the Census Block Groups (CBGs) we have.&amp;nbsp; Now I know this is far from scientific, but we were thinking for the CBGs that only partially overlap the shed layers, calculate the percentage of the overlap, place that percentage in a field, and multiply statistics by that percentage.&amp;nbsp; I've been working on this script for over a week now and I simply cannot get it to work right.&amp;nbsp; Basically what I want it to do is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Create an Update Cursor in the CBGs layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Select each CBG polygon as it scrolls through&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Clip the "shed" layer to the selected polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Measure the shape area for the clipped layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Divide the area of the clipped layer by the CBG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Set the result as the value in the percentage field in CBG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Delete the clipped polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Repeat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;In its current form the script is completing without error, but with whole numbers that clearly are not the desired percentage.&amp;nbsp; Every time I try to create an AddMessage so that I can see what values are being divided I then get an error and am still unable to see where the values are coming.&amp;nbsp; This is the first time I've ever built a python script without step-by-step instructions so I'm very lost.&amp;nbsp; If anyone sees the errors in my code, any pointers would be greatly appreciated.&amp;nbsp; I have the script written below and have attached a zipped folder with the .py, the bikeshed, a few selected CBGs, and the toolbox I'm executing it with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;import arcpy&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;censuslayer = arcpy.GetParameter(0)#census unit layer&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;percentField = arcpy.GetParameter(1)#field where percentage will be input&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;studylayer = arcpy.GetParameter(2)#walk or bikeshed layer&lt;/SPAN&gt;



&lt;SPAN style="font-family: courier new,courier;"&gt;#currently unused#arcpy.AddField_management (censuslayer, "perc_cov", "float", "3", "3") #adds blank percentage field to census units&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;censussize = arcpy.AddField_management (censuslayer, "shapearea", "FLOAT")#adds shape area to census&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.CalculateField_management (censuslayer, "shapearea", "!shape.area@squarefeet!", "PYTHON") #calculates the geometry&lt;/SPAN&gt;


&lt;SPAN style="font-family: courier new,courier;"&gt;#for polygon in studylayer:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.AddField_management (studylayer, "shapearea", "FLOAT") #adds a shape area to walk or bikeshed&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#search = arcpy.SearchCursor(censuslayer)&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;update = arcpy.UpdateCursor(censuslayer)#creates update cursor to move through census layers&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;for row in update:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ceblocksize=float(row.getValue("shapearea"))#places shape area value in variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentCen=int(row.getValue("OBJECTID"))#places object ID field name in variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; holder=("in_memory\holder")#output&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause=str("'OBJECTID' = " + "'"+ str(currentCen)+"'")#formula to indicate record to select&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectBlock=arcpy.Select_analysis(censuslayer, holder, whereClause)#select record where cursor should be&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temppolygon = arcpy.Clip_analysis (studylayer, selectBlock, "templayer") #clip shape from shed layer to selected feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; studysize = arcpy.CalculateField_management (temppolygon, "shapearea", "!shape.area@squarefeet!", "PYTHON") #calculate geometry&amp;nbsp; of clipped feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; studysearch = arcpy.SearchCursor(temppolygon)# new cursor in clipped feature&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for only in studysearch:&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shedsize = only.getValue("shapearea")#store the shape area in a variable&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.AddMessage(shedsize"/"ceblocksize)&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent = float(shedsize)/ceblocksize #get the value to place in new field&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(percentField, percent)#sets the value in field&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; update.updateRow(row)&lt;/SPAN&gt;

&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(temppolygon)#deletes the clipped polygon&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = update.next&lt;/SPAN&gt;


&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; Edit: Formatted Code Block &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370540#M29291</guid>
      <dc:creator>DanielInterrante1</dc:creator>
      <dc:date>2021-12-11T17:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370541#M29292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll just leave this here while someone in the community works on posting an answer to your question &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2015 19:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370541#M29292</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-02-13T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370542#M29293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2015 20:06:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370542#M29293</guid>
      <dc:creator>DanielInterrante1</dc:creator>
      <dc:date>2015-02-13T20:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370543#M29294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the following, see if this is what you are after:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

census =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #census unit feature class&amp;nbsp; 
percentField=&amp;nbsp;&amp;nbsp; #field where percentage will be input&amp;nbsp; 
study =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #walk or bikeshed feature class&amp;nbsp; 

#make feature layer for using with SelectLayerByLocation
arcpy.MakeFeatureLayer_management(census, "census")

#make search cursor over study areas, even if just one.
studyCursor = arcpy.da.SearchCursor(study, ["OID@", "SHAPE@"])
for oid, s_shape in studyCursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #for given study area, select census blocks that intersect
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("census", "INTERSECT", s_shape)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #make update cursor for census blocks selected above
&amp;nbsp;&amp;nbsp;&amp;nbsp; censusCursor = arcpy.da.UpdateCursor("census", ["SHAPE@", percentField])
&amp;nbsp;&amp;nbsp;&amp;nbsp; for c_shape, _ in censusCursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #get area of census block
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; area = c_shape.area

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #find pct of census block that intersects study area
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pct = c_shape.intersect(s_shape, 4).area / area * 100

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #update record
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; censusCursor.updateRow([c_shape, pct])
&amp;nbsp;&amp;nbsp;&amp;nbsp; del censusCursor
del studyCursor&lt;/PRE&gt;&lt;P&gt;The code above is designed to be run as a standalone script, not as a Python tool.&amp;nbsp; If the functional code works for you, it can be moved into a Python tool without much effort.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370543#M29294</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T17:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370544#M29295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I just came across this post and have a similar requirement.&lt;/P&gt;&lt;P&gt;I copied the code above and added in a line to add the percentField field, (works fine) however get the following eror message regarding the pct line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PYTHON ERRORS:&lt;/P&gt;&lt;P&gt;Traceback info:&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Data\python\Percenatge_overlap.py", line 22, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pct = c_shape.intersect(s_shape, 4).area / area * 100&lt;/P&gt;&lt;P&gt;Error Info:&lt;/P&gt;&lt;P&gt;&amp;lt;geoprocessing describe geometry object object at 0x0EB9A4E0&amp;gt;&lt;/P&gt;&lt;P&gt;ArcPy ERRORS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fwiw I'm on Win 7 x64, arcgis 10.2.1, Python 2.7.5&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 00:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370544#M29295</guid>
      <dc:creator>PeterShoemark</dc:creator>
      <dc:date>2016-05-02T00:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370545#M29296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# actually a check to see if the shape is not null first
area = c_shape.area 
 #find pct of census block that intersects study area 
if not(c_shape.disjoint(s_shape)):

&amp;nbsp;&amp;nbsp;&amp;nbsp; pct = c_shape.intersect(s_shape, 4).area / area * 100
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; area = 0.0
#update record 
 censusCursor.updateRow([c_shape, pct])&amp;nbsp; &lt;/PRE&gt;&lt;P&gt;whether that is the cause of the error or not.... a check for 0 for the overlap should be made.... think about it... what if the polygons don't overlap? you shouldn't be dividing by 0.&amp;nbsp; So pay attention to c_shape and s_shape to ensure that they exist and are not null (they should be ok), bt the intersect may be the issue&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370545#M29296</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T17:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370546#M29297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I should have thought to add the checker and have now done so.&lt;/P&gt;&lt;P&gt;Unfortunately I still get the same error message.&lt;/P&gt;&lt;P&gt;Note I failed to mention the data sets are in a gdb just in case that makes a difference.&lt;/P&gt;&lt;P&gt;I can confirm both polygon data sets exist and and a 'select where completely within' returns the following result.&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;Study count = 4230&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;Census count = 374&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;(A min bounding rec is nominally the same for both sets of polygons)&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;Study polygons completely within Census = 2186&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;I believe that would confirm that there are 2044 that have some degree of overlap of the Census polygons.&lt;/P&gt;&lt;P style="margin-left: 36.0pt;"&gt;Does that sound correct?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 01:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370546#M29297</guid>
      <dc:creator>PeterShoemark</dc:creator>
      <dc:date>2016-05-02T01:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370547#M29298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When doing something similar I found it necessary to check disjoint &amp;amp; touching...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# if not disjoint and not touching, must intersect
if not geom1.disjoint(geom2) and not geom1.touches(geom2):&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:10:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370547#M29298</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-11T17:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370548#M29299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the input to date. Unfortunately time is against me and after some further research I achieved my goal through &lt;A href="http://support.esri.com/de/knowledgebase/techarticles/detail/38078" title="http://support.esri.com/de/knowledgebase/techarticles/detail/38078"&gt;38078 - Calculate the percentage of area for polygons&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am however keen to continue to chase a solution to the code provided by Joshua for automation and consistency purposes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 01:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370548#M29299</guid>
      <dc:creator>PeterShoemark</dc:creator>
      <dc:date>2016-05-03T01:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370549#M29300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there anything after "ArcPy ERRORS?"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I don't think Esri's geometry validation tools are that robust, they do occasionally find issues.&amp;nbsp; Where the error is occurring makes me think you may have an invalid geometry in one of the datasets.&amp;nbsp; If you run Check Geometry on the datasets, does it return anything?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thought is projections.&amp;nbsp; Do both datasets have projections?&amp;nbsp; Are they the same projection?&amp;nbsp; What if you reproject both datasets into the same projection, does the error go away?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One final thought, any ZM polygons?&amp;nbsp; I have occasionally had issues with ArcPy Geometry classes and Z, M, or ZM polygons.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 13:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370549#M29300</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-03T13:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Mesuring Percentage of Feature Polygons that Overlap Each Other in Python</title>
      <link>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370550#M29301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like bad geometry (self overlaps) as I did manage to run it cleanly on a small subset. I will do a clean up and try again but maybe a day or so yet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2016 06:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mesuring-percentage-of-feature-polygons-that/m-p/370550#M29301</guid>
      <dc:creator>PeterShoemark</dc:creator>
      <dc:date>2016-05-05T06:23:10Z</dc:date>
    </item>
  </channel>
</rss>

