<?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: Arcpy writes a shapefile with wrong coordinates in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030457#M37898</link>
    <description>&lt;P&gt;Thank you very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2021 14:51:19 GMT</pubDate>
    <dc:creator>OlesiaIgnateva</dc:creator>
    <dc:date>2021-02-25T14:51:19Z</dc:date>
    <item>
      <title>Arcpy writes a shapefile with wrong coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030436#M37891</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I want to write a polygon shapefile from a dictionary with vertices coordinates using arcpy, here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def _getShp (inFC, outFC, vertices):

# this is the method using arcpy
# Create a new polygon feature class using coordinates.
# Each coordinate entry is in the format of {ID: [(X1,Y1), (X2,Y2)....]}
cur = None
try:
    # Create the output feature class
    arcpy.CreateFeatureclass_management(os.path.dirname(outFC),
    os.path.basename(outFC),
    "POLYGON")
    # Access spatial reference of template to define spatial
    # reference of geometries
    spatial_reference = arcpy.Describe(inFC).spatialReference
    # Open an insert cursor for the new feature class
    cur = arcpy.da.InsertCursor(outFC, ["SHAPE@"])
    # Create an array object needed to create features
    # Initialize a variable for keeping track of a feature's ID.
    # ID = -1
    for fid in range(len(vertices.keys())):
        array = arcpy.Array()
        # Add the point to the feature's array of points
        # If the ID has changed, create a new feature
        for i in range(len(vertices[fid])):
            array.add(arcpy.Point(vertices[fid][i][0], vertices[fid][i][1],  ID=fid))

        polygon = arcpy.Polygon(array, spatial_reference)
        cur.insertRow([polygon])
except Exception as e:
    print(e)
finally:
# Clean up the cursor if necessary
    if cur:
       del cur&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that it writes my file wrong. Instead of positive number of X coordinate it writes a negative number, while the Y coordinate stays the same, e.g. the coordinates were around&amp;nbsp;+381462 and became -367560. The coordinate system is WGS 39N. In the end I have got a wrong location. What's wrong could be in the code? Please find a screenshots in attached, but don't look at the polygons' shape, it is another problem I am aware of it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Снимок экрана 2021-02-25 151242.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6895iCD092B666EBB6BC0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Снимок экрана 2021-02-25 151242.jpg" alt="Снимок экрана 2021-02-25 151242.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Снимок экрана 2021-02-25 151218.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6894i5D51A44140CF16FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Снимок экрана 2021-02-25 151218.jpg" alt="Снимок экрана 2021-02-25 151218.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:50:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030436#M37891</guid>
      <dc:creator>OlesiaIgnateva</dc:creator>
      <dc:date>2021-02-25T14:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy writes a shapefile with wrong coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030454#M37896</link>
      <description>&lt;P&gt;not too sure, can you try assigning the spatial reference with an EPSG code rather than a template?&lt;/P&gt;&lt;P&gt;also in:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;array.add(arcpy.Point(vertices[fid][i][0], vertices[fid][i][1], ID=fid))&lt;/LI-CODE&gt;&lt;P&gt;I guess it should be "ID" not ID (which you have as a variable set to -1 - also not sure what that ID of -1 is meant to be doing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally please use the code formatting available to make it readable, all the indents are gone in what you've posted.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:41:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030454#M37896</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-25T14:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy writes a shapefile with wrong coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030456#M37897</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - GeoNet, The Esri Community&lt;/A&gt;&amp;nbsp;is the link for formatting&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:46:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030456#M37897</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-25T14:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy writes a shapefile with wrong coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030457#M37898</link>
      <description>&lt;P&gt;Thank you very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-writes-a-shapefile-with-wrong-coordinates/m-p/1030457#M37898</guid>
      <dc:creator>OlesiaIgnateva</dc:creator>
      <dc:date>2021-02-25T14:51:19Z</dc:date>
    </item>
  </channel>
</rss>

