<?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 Problem with geometry methods - Within/Contains in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215875#M7404</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to check if a polygon is within a mask, which is another polygon. To do this, I use the method CONTAINS. However, this method seems to be wrong because it returns FALSE but in fact it should be TRUE.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attaching here the mask shapefile and below is the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;def createPolygonCell(intCellsize, leftX, upperY):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1.X = leftX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1.Y = upperY&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2.X = leftX + intCellsize&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2.Y = upperY&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3.X = leftX + intCellsize&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3.Y = upperY - intCellsize&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4.X = leftX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4.Y = upperY - intCellsize&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array= arcpy.Array()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint3)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint4)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint1)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPolygon = arcpy.Polygon(array)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return aPolygon&lt;BR /&gt;&lt;BR /&gt;rows = arcpy.SearchCursor(inMaskShp)&amp;nbsp; #inMaskShp is the input mask shapefile attached&lt;BR /&gt;row = rows.next()&lt;BR /&gt;inMask = row.getValue("Shape")&amp;nbsp;&amp;nbsp; #inMask is the first polygon of the inMaskShp&lt;BR /&gt;&lt;BR /&gt;apoly = createPolygonCell(30, 565845, 3881985)&lt;BR /&gt;apoly.within(inMask)&amp;nbsp;&amp;nbsp; #this returns FALSE although it should be TRUE&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do export inMask and apoly to shapefiles to double check whether apoly is within inMask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, the method CONTAINS returns FALSE as well. And it is not correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition, interestingly, the four corners of the apoly (which is a little square) are within inMask when I use apoint.within(inMask).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone please shed a light on this (i.e. how to check a poly within another poly)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Mar 2011 02:56:52 GMT</pubDate>
    <dc:creator>TrungTran</dc:creator>
    <dc:date>2011-03-17T02:56:52Z</dc:date>
    <item>
      <title>Problem with geometry methods - Within/Contains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215875#M7404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to check if a polygon is within a mask, which is another polygon. To do this, I use the method CONTAINS. However, this method seems to be wrong because it returns FALSE but in fact it should be TRUE.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attaching here the mask shapefile and below is the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;def createPolygonCell(intCellsize, leftX, upperY):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4 = arcpy.Point()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1.X = leftX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint1.Y = upperY&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2.X = leftX + intCellsize&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint2.Y = upperY&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3.X = leftX + intCellsize&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint3.Y = upperY - intCellsize&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4.X = leftX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPoint4.Y = upperY - intCellsize&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array= arcpy.Array()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint3)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint4)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(aPoint1)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aPolygon = arcpy.Polygon(array)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.removeAll()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return aPolygon&lt;BR /&gt;&lt;BR /&gt;rows = arcpy.SearchCursor(inMaskShp)&amp;nbsp; #inMaskShp is the input mask shapefile attached&lt;BR /&gt;row = rows.next()&lt;BR /&gt;inMask = row.getValue("Shape")&amp;nbsp;&amp;nbsp; #inMask is the first polygon of the inMaskShp&lt;BR /&gt;&lt;BR /&gt;apoly = createPolygonCell(30, 565845, 3881985)&lt;BR /&gt;apoly.within(inMask)&amp;nbsp;&amp;nbsp; #this returns FALSE although it should be TRUE&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do export inMask and apoly to shapefiles to double check whether apoly is within inMask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, the method CONTAINS returns FALSE as well. And it is not correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition, interestingly, the four corners of the apoly (which is a little square) are within inMask when I use apoint.within(inMask).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone please shed a light on this (i.e. how to check a poly within another poly)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2011 02:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215875#M7404</guid>
      <dc:creator>TrungTran</dc:creator>
      <dc:date>2011-03-17T02:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with geometry methods - Within/Contains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215876#M7405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;without examining the details of your situation in detail, you should be aware that problems have been discovered when using arcpy's geometry objects when no spatial reference is specified.&amp;nbsp; a protracted discussion is noted in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/9763-Errors-in-arcpy-s-Polygon-class"&gt;http://forums.arcgis.com/threads/9763-Errors-in-arcpy-s-Polygon-class&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;there is a NIM number which you can track the error on&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM059845&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which indicates that it is resolved as of version 10 SP2 and in 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/content/nimbus-bug?bugID=TklNMDU5ODQ1"&gt;http://resources.arcgis.com/content/nimbus-bug?bugID=TklNMDU5ODQ1&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2011 04:18:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215876#M7405</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-03-17T04:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with geometry methods - Within/Contains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215877#M7406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Dan. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please let me know where I can download SP2? I just can't find it myself. Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;without examining the details of your situation in detail, you should be aware that problems have been discovered when using arcpy's geometry objects when no spatial reference is specified.&amp;nbsp; a protracted discussion is noted in:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/9763-Errors-in-arcpy-s-Polygon-class"&gt;http://forums.arcgis.com/threads/9763-Errors-in-arcpy-s-Polygon-class&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;there is a NIM number which you can track the error on&lt;BR /&gt;&lt;BR /&gt;NIM059845&lt;BR /&gt;&lt;BR /&gt;which indicates that it is resolved as of version 10 SP2 and in 10.2&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/content/nimbus-bug?bugID=TklNMDU5ODQ1"&gt;http://resources.arcgis.com/content/nimbus-bug?bugID=TklNMDU5ODQ1&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2011 18:04:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215877#M7406</guid>
      <dc:creator>TrungTran</dc:creator>
      <dc:date>2011-03-17T18:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with geometry methods - Within/Contains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215878#M7407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't think it is out yet...so use the workaround in the interim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2011 18:33:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215878#M7407</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-03-17T18:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with geometry methods - Within/Contains</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215879#M7408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK. Thanks Dan.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I don't think it is out yet...so use the workaround in the interim&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2011 18:39:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-with-geometry-methods-within-contains/m-p/215879#M7408</guid>
      <dc:creator>TrungTran</dc:creator>
      <dc:date>2011-03-17T18:39:07Z</dc:date>
    </item>
  </channel>
</rss>

