<?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 make clusters from small polygons with constraint of boundary touching? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3262#M10</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren's method should work, and this is an alternative.&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;# make table of pair of zero distance
arcpy.GenerateNearTable_analysis(fcOrig, fcOrig, tblNear, "0", 
&amp;nbsp;&amp;nbsp;&amp;nbsp; "NO_LOCATION", "NO_ANGLE", "CLOSEST", "0")

if int(arcpy.GetCount_management(tblNear).getOutput(0)) &amp;gt; 0:
&amp;nbsp; # grab ids that showed up in the table 
&amp;nbsp; ids = set([ _[0] for _ in&amp;nbsp; arcpy.da.SearchCursor(tblNear,('IN_FID'))])

&amp;nbsp; # grab shape 
&amp;nbsp; oid = arcpy.Describe(fcOrig).OIDFieldName
&amp;nbsp; outpoly = [_[0] for _ in arcpy.da.SearchCursor(fcOrig, [ 'SHAPE@, oid]) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _[1] in ids ]

&amp;nbsp; # save
&amp;nbsp; arcpy.CopyFeatures_management(outpoly, fcTouching)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:08:35 GMT</pubDate>
    <dc:creator>yosukekimura</dc:creator>
    <dc:date>2021-12-10T20:08:35Z</dc:date>
    <item>
      <title>how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3258#M6</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to make some clusters from a bunch of small polygons with the constraint that each basic unit (polygon) in the resultant cluster must share a portion of its boundary with at least one other basic unit (polygon) in the same cluster. This is becuase of the reason that i want the resultant clusters contagious.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 19:06:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3258#M6</guid>
      <dc:creator>waqarahmad</dc:creator>
      <dc:date>2015-03-11T19:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3259#M7</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do you want to deal with overlapping polygons (e.g. area of smaller polygon may fully overlap, but boundary may be far inside the larger polygon)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 20:23:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3259#M7</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-11T20:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3260#M8</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can pull out polygons intersecting at least one other polygon using the following script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; polys = []
... outPolys = []
... with arcpy.da.SearchCursor("YOUR_POLYGON_LAYER_HERE","SHAPE@") as cursor:
...&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polys.append(row[0])
... for i in range(len(polys)):
...&amp;nbsp;&amp;nbsp;&amp;nbsp; overlap = 0
...&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in range(len(polys)):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if polys&lt;I&gt;.distanceTo(polys&lt;J&gt;) == 0:&lt;/J&gt;&lt;/I&gt;
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; overlap = overlap + 1
...&amp;nbsp;&amp;nbsp;&amp;nbsp; if overlap &amp;gt; 1:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outPolys.append(polys&lt;I&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/I&gt;
... arcpy.CopyFeatures_management(outPolys,'in_memory\polys')&lt;/PRE&gt;&lt;P&gt;&lt;IMG alt="1.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/72496_1.png" style="width: 620px; height: 591px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="2.png" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/72599_2.png" style="width: 620px; height: 591px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:08:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3260#M8</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T20:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3261#M9</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't tested, but&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.disjoint(q)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;intead of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.distanceTo(q)==0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;may runs faster particularly when there are a bunch of polygon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your method is O(n^2) so may have trouble with large number of polygons...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 00:41:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3261#M9</guid>
      <dc:creator>yosukekimura</dc:creator>
      <dc:date>2015-03-12T00:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3262#M10</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren's method should work, and this is an alternative.&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;# make table of pair of zero distance
arcpy.GenerateNearTable_analysis(fcOrig, fcOrig, tblNear, "0", 
&amp;nbsp;&amp;nbsp;&amp;nbsp; "NO_LOCATION", "NO_ANGLE", "CLOSEST", "0")

if int(arcpy.GetCount_management(tblNear).getOutput(0)) &amp;gt; 0:
&amp;nbsp; # grab ids that showed up in the table 
&amp;nbsp; ids = set([ _[0] for _ in&amp;nbsp; arcpy.da.SearchCursor(tblNear,('IN_FID'))])

&amp;nbsp; # grab shape 
&amp;nbsp; oid = arcpy.Describe(fcOrig).OIDFieldName
&amp;nbsp; outpoly = [_[0] for _ in arcpy.da.SearchCursor(fcOrig, [ 'SHAPE@, oid]) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _[1] in ids ]

&amp;nbsp; # save
&amp;nbsp; arcpy.CopyFeatures_management(outpoly, fcTouching)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:08:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3262#M10</guid>
      <dc:creator>yosukekimura</dc:creator>
      <dc:date>2021-12-10T20:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to make clusters from small polygons with constraint of boundary touching?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3263#M11</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have only polygons which touching EACH OTHER'S boundry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 21:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-make-clusters-from-small-polygons-with/m-p/3263#M11</guid>
      <dc:creator>waqarahmad</dc:creator>
      <dc:date>2015-03-12T21:24:52Z</dc:date>
    </item>
  </channel>
</rss>

