<?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 Python Add-In Q: Polygons in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-add-in-q-polygons/m-p/84409#M6660</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to replicate the Select By Polygon tool (minus the selecting step).&amp;nbsp; I simply need to be able to draw a temporary polygon to 'do stuff' with.&amp;nbsp; What am I missing here? --- I see a way to set self.shape to Line, Circle or Rectanlge but there is no Polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can set self.shape to "Line" and then create an array of points in the onLine def, but this is not what the SelectByPolygon tool is doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help with this seemingly simple process.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;j&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 May 2013 14:14:18 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2013-05-07T14:14:18Z</dc:date>
    <item>
      <title>Python Add-In Q: Polygons</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-q-polygons/m-p/84409#M6660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to replicate the Select By Polygon tool (minus the selecting step).&amp;nbsp; I simply need to be able to draw a temporary polygon to 'do stuff' with.&amp;nbsp; What am I missing here? --- I see a way to set self.shape to Line, Circle or Rectanlge but there is no Polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can set self.shape to "Line" and then create an array of points in the onLine def, but this is not what the SelectByPolygon tool is doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help with this seemingly simple process.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;j&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 14:14:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-q-polygons/m-p/84409#M6660</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-05-07T14:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In Q: Polygons</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-q-polygons/m-p/84410#M6661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not completely satisfied with this solution, but it accomplishes what I need --- return the area, acreage for the shape that is drawn in the map display.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; I Need to add some spatial reference checks on the DataFrame.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; The &amp;lt;self.shape = "Line"&amp;gt; is not quite doing what I want (interactively draw a polygon).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; This is drawing a line, I'd rather it draw a polygon (as you click each vertex, the polygon begins to take shape, just like in the SelectByPolygon tool).&amp;nbsp; As it stands, I can tell that the user will be confused on how to close the polygon (really it should only take 4 clicks to create a simple rectangle/polygon, but because it is a line the user will want to "close" the polygon and click that 5th vertex).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How about interactively creaing a polygon graphic element?&amp;nbsp; I don't see how this can be converted to such a thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway -- this returns the correct acreage when the DataFrame's coordinate system properties are correctly set:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; class ToolClass_AcresByClicks(object): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for EOCTools_addin.tool (Tool)""" &amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.shape = "Line"&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; def onLine(self, line_geometry): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array = arcpy.Array() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part = line_geometry.getPart(0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pt in part: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pt) &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t_polygon = arcpy.Polygon(array) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parea = t_polygon.area &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_acreage = parea / 43560 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print p_acreage &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 17:49:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-q-polygons/m-p/84410#M6661</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-05-07T17:49:00Z</dc:date>
    </item>
  </channel>
</rss>

