<?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: ArcGIS 10.0: Python Window - Try to Create 3 polygons, but no 3rd polygon showed in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715357#M55517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake,&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your valuable response.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The extra lines/space after the last line of input data is a big devil and wasted me so much time!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott Chang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2012 16:33:49 GMT</pubDate>
    <dc:creator>ScottChang</dc:creator>
    <dc:date>2012-09-28T16:33:49Z</dc:date>
    <item>
      <title>ArcGIS 10.0: Python Window - Try to Create 3 polygons, but no 3rd polygon showed up</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715354#M55514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I created the following ArcPy-Python script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# ===== newWritingGeometries3Polygons in PythonWin 2.6.5 ========
# Create a new polygon feature class using a text file of coordinates.
#&amp;nbsp;&amp;nbsp; Each coordinate entry is semicolon delimited in the format of ID;X;Y

# Import ArcPy and other required modules
#
import arcpy
from arcpy import env
import fileinput
import string
import os

env.overwriteOutput = True

# Get the coordinate ASCII file
#
#infile = arcpy.GetParameterAsText(0)
infile = r"C:\TEMP\WritingGeometries\WritingGeometries_3features.txt"

# Get the output feature class
# fcname = arcpy.GetParameterAsText(1)
fcname = r"C:\TEMP\BS_Test.gdb\Polygons_fc"

# Get the template feature class
#
# template = arcpy.GetParameterAsText(2)
template = r"C:\TEMP\BS_Test.gdb\bsInFeatureClass"

try:
&amp;nbsp;&amp;nbsp; # Create the output feature class
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(os.path.dirname(fcname),
&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;&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;&amp;nbsp;&amp;nbsp; os.path.basename(fcname), 
&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;&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;&amp;nbsp;&amp;nbsp; "Polygon", template)

&amp;nbsp;&amp;nbsp; # Open an insert cursor for the new feature class
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; cur = arcpy.InsertCursor(fcname)

&amp;nbsp;&amp;nbsp; # Create an array and point object needed to create features
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; polygonArray = arcpy.Array()
&amp;nbsp;&amp;nbsp; pnt = arcpy.Point()

&amp;nbsp;&amp;nbsp; # Initialize a variable for keeping track of a feature's ID.
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; ID = -1 
&amp;nbsp;&amp;nbsp; for line in fileinput.input(infile): # Open the input file
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set the point's ID, X and Y properties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.ID, pnt.X, pnt.Y = string.split(line,";")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pnt.ID, pnt.X, pnt.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ID == -1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = pnt.ID

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add the point to the feature's array of points
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; If the ID has changed, create a new feature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ID != pnt.ID:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a new row or feature, in the feature class
&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; feat = cur.newRow()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set the geometry of the new feature to the array of points
&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; feat.shape = polygonArray

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Insert the feature
&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; cur.insertRow(feat)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygonArray.removeAll()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygonArray.add(pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = pnt.ID

&amp;nbsp;&amp;nbsp; # Add the last feature
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; feat = cur.newRow()
&amp;nbsp;&amp;nbsp; feat.shape = polygonArray
&amp;nbsp;&amp;nbsp; cur.insertRow(feat)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; lineArray.removeAll()
&amp;nbsp;&amp;nbsp; fileinput.close()
&amp;nbsp;&amp;nbsp; del cur
&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText (0, fcname) # newly added 18Sept2012, per Barbara S.
except Exception as e:
&amp;nbsp;&amp;nbsp; print e.message
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I executed the script and I just got 2 polygons - see the attached file for details.&amp;nbsp; Please kindly help and tell me why the 3rd polygon failed to show up ( I believe the following code staments do not work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Add the last feature
&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp; feat = cur.newRow()
&amp;nbsp;&amp;nbsp; feat.shape = polygonArray
&amp;nbsp;&amp;nbsp; cur.insertRow(feat)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott Chang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 19:22:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715354#M55514</guid>
      <dc:creator>ScottChang</dc:creator>
      <dc:date>2012-09-27T19:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.0: Python Window - Try to Create 3 polygons, but no 3rd polygon showed</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715355#M55515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I forgot to attach the text file of ID, and X,Y-coordinates for the 3 polygons to be created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please see the attached file in this thread for the text file of ID, and X,Y-coordinates for the 3 polygons to be created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott Chang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 11:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715355#M55515</guid>
      <dc:creator>ScottChang</dc:creator>
      <dc:date>2012-09-28T11:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.0: Python Window - Try to Create 3 polygons, but no 3rd polygon showed</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715356#M55516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Scott,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remove the extra lines after the last line in the text file and it should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 11:52:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715356#M55516</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-09-28T11:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.0: Python Window - Try to Create 3 polygons, but no 3rd polygon showed</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715357#M55517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake,&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your valuable response.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The extra lines/space after the last line of input data is a big devil and wasted me so much time!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Scott Chang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 16:33:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-0-python-window-try-to-create-3-polygons/m-p/715357#M55517</guid>
      <dc:creator>ScottChang</dc:creator>
      <dc:date>2012-09-28T16:33:49Z</dc:date>
    </item>
  </channel>
</rss>

