<?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 create a simple square polygon and add it to a feature class. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278805#M21554</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try specifying the spatial reference when you create your polygon:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python" style="border-width: 0px 0px 0px 2px; border-style: initial initial initial solid; border-color: initial initial initial #cccccc; margin: 10px 0px; padding: 0px 0px 0px 20px;"&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;polygon &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Polygon&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;array&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;spatialref&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Dec 2016 19:53:25 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2016-12-05T19:53:25Z</dc:date>
    <item>
      <title>How to create a simple square polygon and add it to a feature class.</title>
      <link>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278804#M21553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, the code below is a part of a much larger script. Within that larger script i have already successfully created and written geometries to two polyline feature classes and two point feature classes. I would like to now create and write geometries to a polygon feature class. However, every time i attempt to use "arcpy.Polygon()" the resulting object is empty despite the point objects and array object that i pass to "arcpy.Polygon()" not being empty. Am i missing something here? Every time i try and create a polygon object it is empty no matter what i pass to it. Any help would be greatly appreciated.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, arcpy

infc = r"C:\Users\User\GIS\single_section.shp"
polygons = r"C:\Users\User\GIS\polygons.shp"

spatialref = arcpy.Describe(infc).spatialReference

if arcpy.Exists(polygons):
 arcpy.Delete_management(polygons)
 
arcpy.CreateFeatureclass_management(*os.path.split(polygons), geometry_type="Polygon", spatial_reference=spatialref.factoryCode)

icursor = arcpy.da.InsertCursor(polygons, ["SHAPE@"])

TLX = -104.357483001
TLY = 32.2242740047
TRX = -104.341346746
TRY = 32.2241446297
BRX = -104.356403497
BRY = 32.2233637742
BLX = -104.357479189
BLY = 32.2233727547

array = arcpy.Array()
array.add(arcpy.Point(TLX,TLY))
array.add(arcpy.Point(TRX,TRY))
array.add(arcpy.Point(BRX,BRY))
array.add(arcpy.Point(BLX,BLY))
array.add(arcpy.Point(TLX,TLY))

polygon = arcpy.Polygon(array)

icursor.insertRow([polygon])&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278804#M21553</guid>
      <dc:creator>BrandonZaitz</dc:creator>
      <dc:date>2021-12-12T16:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a simple square polygon and add it to a feature class.</title>
      <link>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278805#M21554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try specifying the spatial reference when you create your polygon:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python" style="border-width: 0px 0px 0px 2px; border-style: initial initial initial solid; border-color: initial initial initial #cccccc; margin: 10px 0px; padding: 0px 0px 0px 20px;"&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;polygon &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Polygon&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;array&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;spatialref&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 19:53:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278805#M21554</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-12-05T19:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a simple square polygon and add it to a feature class.</title>
      <link>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278806#M21555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply. Yeah, that solved my problem. I actually managed to figure it out just a few minutes before seeing your reply. This was really vexing me for a few hours. Just seems strange to me that i would have to define a spatial reference when creating a polygon object but not a polyline...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 22:06:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278806#M21555</guid>
      <dc:creator>BrandonZaitz</dc:creator>
      <dc:date>2016-12-05T22:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a simple square polygon and add it to a feature class.</title>
      <link>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278807#M21556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree that it is inconsistent when you require a spatial reference and when it will let you get away without one, but I've decided that it's worth it to just include a spatial reference every time you a.) create a geometry object, and b.) create a Search or Update cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 22:17:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-create-a-simple-square-polygon-and-add-it/m-p/278807#M21556</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-12-05T22:17:33Z</dc:date>
    </item>
  </channel>
</rss>

