<?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 Flawed Logic: Creating lines from coordinates in geographic coordinate systems in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1559310#M73614</link>
    <description>&lt;P&gt;&lt;FONT size="3" color="#0000FF"&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: This is not actually a question, I am trying to somehow report this issue to Esri but the options available for bug reports don't feel like they're well-suited to this case&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;When creating a 2-vertex Polyline from an Array of PointGeometry objects (via InsertCursor), the line is forcibly created with 0-length (&lt;SPAN&gt;null&lt;/SPAN&gt;) geometry if the distance between the two points is &amp;lt; 0.0002 &lt;SPAN&gt;i&lt;STRONG&gt;n units of the target layer's spatial reference&lt;/STRONG&gt;&lt;/SPAN&gt;. This means that, without a &lt;U&gt;projected&lt;/U&gt; coordinate system, lines &amp;lt; &lt;STRONG&gt;53.5 FEET long &lt;/STRONG&gt;cannot be created!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;arcpy should absolutely assume that &lt;SPAN&gt;any&lt;/SPAN&gt; variation between coordinates is &lt;U&gt;real&lt;/U&gt; and should create a line based on the &lt;SPAN&gt;&lt;STRONG&gt;supplied coordinates&lt;/STRONG&gt;. &lt;/SPAN&gt;It &lt;U&gt;should not&lt;/U&gt; assume something is zero-length based on a rounded or&amp;nbsp;calculated length... and currently it's making that assumption from the &lt;EM&gt;rounding of&amp;nbsp;a calculated length&lt;/EM&gt;! It is possible to manually create a line that measures with a Shape_Length &amp;lt; 0.000001 degrees -- so it should be just as possible to create that line (and any other) with Python&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;Evidence of this cutoff:&amp;nbsp;Result of creating lines in unprojected WGS84 from two-point arrays, where the first point is at [-70.0, 43.0] and the second is at [Latitude, 43.0]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JonahMiller_1-1731694507116.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119680i72FF78BA69A76784/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JonahMiller_1-1731694507116.png" alt="JonahMiller_1-1731694507116.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;&lt;STRONG&gt;In conclusion&lt;/STRONG&gt;:&lt;/SPAN&gt; If you are using arcpy to create polylines and they are unexpectedly returning null geometries, try calculating the length between coordinates. If it's teeny-tiny, you have to use a different coordinate system to make it to work!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;(I discovered this problem because a coworker was getting null geometry from a custom tool we use frequently when running it based on AGOL data that's in WGS84. I fixed it by telling the tool to use that map's spatial reference if the source layer's SC is geographic. I think this sounds like kind of a niche issue, but I can think of numerous ways that it could continue to hassle us down the line if I hadn't identified the reason &amp;amp; solution)&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2024 11:58:56 GMT</pubDate>
    <dc:creator>JonahMiller</dc:creator>
    <dc:date>2024-11-18T11:58:56Z</dc:date>
    <item>
      <title>Flawed Logic: Creating lines from coordinates in geographic coordinate systems</title>
      <link>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1559310#M73614</link>
      <description>&lt;P&gt;&lt;FONT size="3" color="#0000FF"&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: This is not actually a question, I am trying to somehow report this issue to Esri but the options available for bug reports don't feel like they're well-suited to this case&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;When creating a 2-vertex Polyline from an Array of PointGeometry objects (via InsertCursor), the line is forcibly created with 0-length (&lt;SPAN&gt;null&lt;/SPAN&gt;) geometry if the distance between the two points is &amp;lt; 0.0002 &lt;SPAN&gt;i&lt;STRONG&gt;n units of the target layer's spatial reference&lt;/STRONG&gt;&lt;/SPAN&gt;. This means that, without a &lt;U&gt;projected&lt;/U&gt; coordinate system, lines &amp;lt; &lt;STRONG&gt;53.5 FEET long &lt;/STRONG&gt;cannot be created!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;arcpy should absolutely assume that &lt;SPAN&gt;any&lt;/SPAN&gt; variation between coordinates is &lt;U&gt;real&lt;/U&gt; and should create a line based on the &lt;SPAN&gt;&lt;STRONG&gt;supplied coordinates&lt;/STRONG&gt;. &lt;/SPAN&gt;It &lt;U&gt;should not&lt;/U&gt; assume something is zero-length based on a rounded or&amp;nbsp;calculated length... and currently it's making that assumption from the &lt;EM&gt;rounding of&amp;nbsp;a calculated length&lt;/EM&gt;! It is possible to manually create a line that measures with a Shape_Length &amp;lt; 0.000001 degrees -- so it should be just as possible to create that line (and any other) with Python&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;Evidence of this cutoff:&amp;nbsp;Result of creating lines in unprojected WGS84 from two-point arrays, where the first point is at [-70.0, 43.0] and the second is at [Latitude, 43.0]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JonahMiller_1-1731694507116.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119680i72FF78BA69A76784/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JonahMiller_1-1731694507116.png" alt="JonahMiller_1-1731694507116.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;&lt;STRONG&gt;In conclusion&lt;/STRONG&gt;:&lt;/SPAN&gt; If you are using arcpy to create polylines and they are unexpectedly returning null geometries, try calculating the length between coordinates. If it's teeny-tiny, you have to use a different coordinate system to make it to work!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;(I discovered this problem because a coworker was getting null geometry from a custom tool we use frequently when running it based on AGOL data that's in WGS84. I fixed it by telling the tool to use that map's spatial reference if the source layer's SC is geographic. I think this sounds like kind of a niche issue, but I can think of numerous ways that it could continue to hassle us down the line if I hadn't identified the reason &amp;amp; solution)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 11:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1559310#M73614</guid>
      <dc:creator>JonahMiller</dc:creator>
      <dc:date>2024-11-18T11:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Flawed Logic: Creating lines from coordinates in geographic coordinate systems</title>
      <link>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1559364#M73615</link>
      <description>&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-python-api" target="_blank"&gt;Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python&lt;/A&gt;&lt;/P&gt;&lt;P&gt;might be worthwhile raising an "issue" there to shorten the path of notification to those responsible for the api&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 20:21:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1559364#M73615</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-11-15T20:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Flawed Logic: Creating lines from coordinates in geographic coordinate systems</title>
      <link>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1577953#M73621</link>
      <description>&lt;P&gt;Hi Jonah,&lt;/P&gt;&lt;P&gt;&amp;nbsp;tolerance and resolution are determined from the spatialReference associated with the geometry.&amp;nbsp; The spatial reference has details on domain, units, etc... which allows us to set appropriate tolerance and resolution. So best practice is to always set the SpatialReference when creating geometry objects.&lt;/P&gt;&lt;P&gt;When you're creating polyline it should include a spatialReference (eg: "arcpy.SpatialReference(4326)"&amp;nbsp; for&amp;nbsp;&lt;SPAN&gt;WGS84).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;See examples in docs below&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/polyline.htm" target="_self"&gt;Doc: arcpy - Polyline&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/writing-geometries.htm" target="_self"&gt;Doc: arcpy - Write geometries&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;sr = arcpy.SpatialReference(4326)
line1 = arcpy.Polyline(arcpy.Array(...), sr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the absence of a known SpatialReference, you get the Unknown Coordinate system which has a XYTolerance of 0.001 Unknown Units... which for your case (GCS data) means a tolerance of ~111 meters at the equator. With that tolerance and GCS data, many ooperations are performed on the geometry will cause the vertices to snap and line to degenerate.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 19:54:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/flawed-logic-creating-lines-from-coordinates-in/m-p/1577953#M73621</guid>
      <dc:creator>gprince</dc:creator>
      <dc:date>2025-01-22T19:54:56Z</dc:date>
    </item>
  </channel>
</rss>

