<?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: Possible bug: .to_geojson produces invalid GeoJSON from Line features in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864579#M4350</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've logged this as a bug in the API,&amp;nbsp;&lt;A href="https://community.esri.com/people/Ryan.Cooper@raleighnc.gov_ral"&gt;Ryan.Cooper@raleighnc.gov_ral&lt;/A&gt;&amp;nbsp;.&amp;nbsp; When I hear any info about when it's fixed, I'll let you know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Jan 2019 23:39:11 GMT</pubDate>
    <dc:creator>JohnYaist1</dc:creator>
    <dc:date>2019-01-23T23:39:11Z</dc:date>
    <item>
      <title>Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864576#M4347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have come across a potential bug when using the &lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=to_geojson#arcgis.features.FeatureSet.to_geojson" rel="nofollow noopener noreferrer" target="_blank"&gt;.to_geojson&lt;/A&gt; method to&amp;nbsp;convert a feature set object to GeoJSON using the ArcGIS Python API (v1.5.2). While attempting to convert a Feature Set&amp;nbsp;of single-part&amp;nbsp;line geometries to GeoJSON, the API produced invalid GeoJSON. From what I can tell, the API appears to be formatting the coordinates for single-part line geometries as multi-part line geometries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the GeoJSON specification,&amp;nbsp;the &lt;A href="https://tools.ietf.org/html/rfc7946#appendix-A.2" rel="nofollow noopener noreferrer" target="_blank"&gt;geometry of a single part line geometry (LineString)&lt;/A&gt; should look like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"LineString"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="string token"&gt;"coordinates"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;100.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;101.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As you can see here the value for "coordinates" is a single array containing 2 or more coordinate arrays.&amp;nbsp;(&lt;A href="https://tools.ietf.org/html/rfc7946#section-3.1.4" rel="nofollow noopener noreferrer" target="_blank"&gt;Source&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://tools.ietf.org/html/rfc7946#appendix-A.5" rel="nofollow noopener noreferrer" target="_blank"&gt;geometry of a multi-part line geometry (MultiLineString)&lt;/A&gt; should look like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt; 
&amp;nbsp; &lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MultiLineString"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="string token"&gt;"coordinates"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;
&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; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;100.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;101.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
&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; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;102.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;103.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&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; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The value for "coordinates" is a single array containing 2 or more LineString geometries (i.e. a single array containing 2 or more coordinate arrays).&amp;nbsp;(&lt;A href="https://tools.ietf.org/html/rfc7946#section-3.1.5" rel="nofollow noopener noreferrer" target="_blank"&gt;Source&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I use .to_geojson on a single-part line geometry, the following is returned:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"LineString"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="string token"&gt;"coordinates"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;
&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; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;100.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;101.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&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; &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The&amp;nbsp;geometry&amp;nbsp;type value is properly&amp;nbsp; set as a LineString, but the coordinates are formatted as a MultiLineString.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a Jupyter notebook using some sample data of single-part point, line, and polygon datasets:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://github.com/skarplab/python-troubleshooting/tree/to_geojson-linestring" rel="nofollow noopener noreferrer" target="_blank"&gt;Code&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://mybinder.org/v2/gh/skarplab/python-troubleshooting/to_geojson-linestring" rel="nofollow noopener noreferrer" target="_blank"&gt;Interactive Notebook&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This notebook documents my process troubleshooting this issue. Please feel free to take a look, run the code, and offer feedback if I am in error on how I have tried to access single-part line geometries as GeoJSON.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:44:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864576#M4347</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T10:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864577#M4348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice work isolating and demonstrating the issue.&amp;nbsp; It is clearly a bug, I recommend logging it with Esri Support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/45514"&gt;Atma Mani&lt;/A&gt;‌, &lt;A href="https://community.esri.com/migrated-users/2049"&gt;John Yaist&lt;/A&gt;‌, thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2019 16:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864577#M4348</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-01-11T16:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864578#M4349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the thorough report, &lt;A href="https://community.esri.com/people/Ryan.Cooper@raleighnc.gov_ral"&gt;Ryan.Cooper@raleighnc.gov_ral&lt;/A&gt;&amp;nbsp;.&amp;nbsp;Certainly looks like a bug - give me a day or two to run through and try to reproduce it here so I can get it into the system. I'll keep you posted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2019 17:04:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864578#M4349</guid>
      <dc:creator>JohnYaist1</dc:creator>
      <dc:date>2019-01-15T17:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864579#M4350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've logged this as a bug in the API,&amp;nbsp;&lt;A href="https://community.esri.com/people/Ryan.Cooper@raleighnc.gov_ral"&gt;Ryan.Cooper@raleighnc.gov_ral&lt;/A&gt;&amp;nbsp;.&amp;nbsp; When I hear any info about when it's fixed, I'll let you know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2019 23:39:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864579#M4350</guid>
      <dc:creator>JohnYaist1</dc:creator>
      <dc:date>2019-01-23T23:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864580#M4351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A _jive_internal="true" href="https://community.esri.com/people/Ryan.Cooper@raleighnc.gov_ral"&gt;Ryan Cooper&lt;/A&gt;&amp;nbsp;- fyi...we pushed a fix up for this last night, it should be working in the next release. As you suggested, some internal functions were returning geojson as &lt;EM&gt;LineString.&amp;nbsp;&lt;/EM&gt;WE updated it to &lt;EM&gt;MultiLineStrings&lt;/EM&gt; and it fixed it. Thanks for pointing it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2019 18:05:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864580#M4351</guid>
      <dc:creator>JohnYaist1</dc:creator>
      <dc:date>2019-01-25T18:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Possible bug: .to_geojson produces invalid GeoJSON from Line features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864581#M4352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you check for polygons to make sure it outputs MultiPolygon instead of Polygon?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2019 18:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/possible-bug-to-geojson-produces-invalid-geojson/m-p/864581#M4352</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-01-25T18:34:59Z</dc:date>
    </item>
  </channel>
</rss>

