<?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 unsuspected coordinate values when creating polygons with arcpy. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160361#M12281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a problem when creating polygon features with arcpy. I want to save rounded X and Y vertices for example to two decimal places. Example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have coordinates given on two decimal places. I am expecting rounding error due to limitations in precision of float data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say we are working with projected coordinate system with base units of 1 Meter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example script (using dummy coordinate values):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;point_coord = arcpy.Point(1.10, 2.13)&lt;/P&gt;&lt;P&gt;point = arcpy.PointGeometry(point_coord)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linestring_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12)]&lt;/P&gt;&lt;P&gt;ls_array = arcpy.Array(linestring_coords)&lt;/P&gt;&lt;P&gt;linestring = arcpy.Polyline(ls_array)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;poly_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12), arcpy.Point(0.32, 4.2), arcpy.Point(1.10, 2.13)]&lt;/P&gt;&lt;P&gt;p_array = arcpy.Array(arcpy.Array(poly_coords))&lt;/P&gt;&lt;P&gt;poly = arcpy.Polygon(p_array)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print("Constructed point: {}".format(point.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polyline: {}".format(linestring.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polygon: {}".format(poly.WKT))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Constructed point: POINT (1.1000000000000001 2.1299999999999999)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Constructed polyline: MULTILINESTRING ((1.1000000000000001 2.1299999999999999, 2.4399999999999999 5.1200000000000001))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Constructed polygon: MULTIPOLYGON (((1.10009765625 2.130126953125, 2.44012451171875 5.1201171875, 0.32012939453125 4.2000732421875, 1.10009765625 2.130126953125)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As said&amp;nbsp;I am expecting rounding errors on for the values in point and polyline. But error on polygon coordinates is a lot bigger than 10e-10. If we say that base projection units are in meters that brings an &lt;STRONG&gt;error of 0.1 mm&lt;/STRONG&gt; which is a lot in some surveying applications. I know that this error can be virtually rounded to 2 decimal places in arcmap or some other, but if I want to take these coordinates programically and perform some calculations the error grows and stays in data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to enforce rounding to values of coordinates for polygon features. How can this be the case in software meant for managing acurrate and high quality data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know for a fact, that some libraries outside arcgis ecosystem round coordinates normally for polygons (like point and polyline above).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I achieve same 'precision' as&amp;nbsp;when creating polylines but with Polygons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jan 2020 12:37:18 GMT</pubDate>
    <dc:creator>BlažLipuš</dc:creator>
    <dc:date>2020-01-24T12:37:18Z</dc:date>
    <item>
      <title>Problem with unsuspected coordinate values when creating polygons with arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160361#M12281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a problem when creating polygon features with arcpy. I want to save rounded X and Y vertices for example to two decimal places. Example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have coordinates given on two decimal places. I am expecting rounding error due to limitations in precision of float data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say we are working with projected coordinate system with base units of 1 Meter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example script (using dummy coordinate values):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;point_coord = arcpy.Point(1.10, 2.13)&lt;/P&gt;&lt;P&gt;point = arcpy.PointGeometry(point_coord)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linestring_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12)]&lt;/P&gt;&lt;P&gt;ls_array = arcpy.Array(linestring_coords)&lt;/P&gt;&lt;P&gt;linestring = arcpy.Polyline(ls_array)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;poly_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12), arcpy.Point(0.32, 4.2), arcpy.Point(1.10, 2.13)]&lt;/P&gt;&lt;P&gt;p_array = arcpy.Array(arcpy.Array(poly_coords))&lt;/P&gt;&lt;P&gt;poly = arcpy.Polygon(p_array)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print("Constructed point: {}".format(point.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polyline: {}".format(linestring.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polygon: {}".format(poly.WKT))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Constructed point: POINT (1.1000000000000001 2.1299999999999999)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Constructed polyline: MULTILINESTRING ((1.1000000000000001 2.1299999999999999, 2.4399999999999999 5.1200000000000001))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Constructed polygon: MULTIPOLYGON (((1.10009765625 2.130126953125, 2.44012451171875 5.1201171875, 0.32012939453125 4.2000732421875, 1.10009765625 2.130126953125)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As said&amp;nbsp;I am expecting rounding errors on for the values in point and polyline. But error on polygon coordinates is a lot bigger than 10e-10. If we say that base projection units are in meters that brings an &lt;STRONG&gt;error of 0.1 mm&lt;/STRONG&gt; which is a lot in some surveying applications. I know that this error can be virtually rounded to 2 decimal places in arcmap or some other, but if I want to take these coordinates programically and perform some calculations the error grows and stays in data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to enforce rounding to values of coordinates for polygon features. How can this be the case in software meant for managing acurrate and high quality data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know for a fact, that some libraries outside arcgis ecosystem round coordinates normally for polygons (like point and polyline above).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I achieve same 'precision' as&amp;nbsp;when creating polylines but with Polygons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2020 12:37:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160361#M12281</guid>
      <dc:creator>BlažLipuš</dc:creator>
      <dc:date>2020-01-24T12:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with unsuspected coordinate values when creating polygons with arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160362#M12282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are issues if you don't use a defined coordinate system for your data.&amp;nbsp; I didn't see one specified.&lt;/P&gt;&lt;P&gt;specify it when creating the&amp;nbsp;Polygon object&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;poly = arcpy.Polygon(arcpy.Array(aa), SR)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where aa is a list or array of points and SR is a spatial reference object (name, of code is also fine)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm"&gt;Polygon—ArcPy classes | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2020 14:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160362#M12282</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-01-24T14:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with unsuspected coordinate values when creating polygons with arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160363#M12283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Thank you for your fast anwser!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can see what you mean. I didn't think of defining coordinate system for each geometry object since feature class I'm inserting in (in other solution) has spatial reference defined. This fixed the accuracy a lot but it is still not the same as with polyline if we compare first two vertices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sr = arcpy.SpatialReference(3857) #projected coordinate system&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;point_coord = arcpy.Point(1.10, 2.13)&lt;/P&gt;&lt;P&gt;point = arcpy.PointGeometry(point_coord, sr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linestring_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12)]&lt;/P&gt;&lt;P&gt;ls_array = arcpy.Array(linestring_coords)&lt;/P&gt;&lt;P&gt;linestring = arcpy.Polyline(ls_array, sr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;poly_coords = [arcpy.Point(1.10, 2.13), arcpy.Point(2.44, 5.12), arcpy.Point(0.32, 4.2), arcpy.Point(1.10, 2.13)]&lt;/P&gt;&lt;P&gt;p_array = arcpy.Array(arcpy.Array(poly_coords))&lt;/P&gt;&lt;P&gt;poly = arcpy.Polygon(p_array, sr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print("Constructed point: {}".format(point.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polyline: {}".format(linestring.WKT))&lt;/P&gt;&lt;P&gt;print("Constructed polygon: {}".format(poly.WKT))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Constructed point: POINT (1.1000000000000001 2.1299999999999999)&lt;/P&gt;&lt;P&gt;Constructed polyline: MULTILINESTRING ((1.1000000000000001 2.1299999999999999, 2.4399999999999999 5.1200000000000001))&lt;/P&gt;&lt;P&gt;Constructed polygon: MULTIPOLYGON (((1.1000000014901161 2.1299999989569187, 2.4400000013411045 5.1200000010430813, 0.32000000029802322 4.1999999992549419, 1.1000000014901161 2.1299999989569187)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quick follow up question:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How come that polylines and points give right accuracy even without SR defined since they are (from my view) build with same underlying object (arcpy.Point, arcpy.Array)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2020 14:43:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160363#M12283</guid>
      <dc:creator>BlažLipuš</dc:creator>
      <dc:date>2020-01-24T14:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with unsuspected coordinate values when creating polygons with arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160364#M12284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/390647"&gt;Blaž Lipuš&lt;/A&gt;‌&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/polyline.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/polyline.htm"&gt;Polyline—ArcPy classes | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Geometry, Polygon, Polyline, PointGeometry, MultiPoint classes all have a spatial reference... Point does not, nor does Array&lt;/P&gt;&lt;P&gt;Explore the ArcPy classes for more goodies &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2020 15:29:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-unsuspected-coordinate-values-when/m-p/160364#M12284</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-01-24T15:29:39Z</dc:date>
    </item>
  </channel>
</rss>

