<?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 efficiently convert a shapely linestring back into an arcpy polyline? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272364#M67255</link>
    <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;Awesome! It never occurred to me that it would be a function of arcpy, I was looking for some sort of read/write property of a geometry.&amp;nbsp; Well you have definitely earned yourself a&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beer_mug:"&gt;🍺&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for your swift reply.&lt;/P&gt;&lt;P&gt;Duncan&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2023 10:43:43 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2023-03-28T10:43:43Z</dc:date>
    <item>
      <title>How to efficiently convert a shapely linestring back into an arcpy polyline?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272354#M67252</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;I'm hoping to tap into the python community for advice on how to efficiently convert a shapely linestring back into an arcpy polyline.&amp;nbsp; I am developing a suite of python tools in the ArcPro 3.1.0 toolbox (atbx).&lt;/P&gt;&lt;P&gt;So I read from a file geodatabase polyline geometries and convert them to a shapely linestring. I do this as shapely exposes a useful method on a polyline that does not exist in the arcpy.&amp;nbsp; A simplified snippet of my reading code (which works fine) is shown below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from shapely.wkb import loads
with arcpy.da.SearchCursor(mylayer, ["SHAPE@WKB"]) as cursor:
    for row in cursor:
        geom = row[0]
        line = loads(bytes(geom))  # Convert arcpy geometry into shapely geometry
        # Do something with line using shapely
&lt;/LI-CODE&gt;&lt;P&gt;Later on in my code I want to write the processed shapely linestring back into a new Feature Class using an insert cursor.&lt;/P&gt;&lt;P&gt;What I cannot work out, hence me coming to you, is how do I efficiently turn a linestring back into an arcpy polyline geometry so I can write it back to a new file geodatabase feature class?&amp;nbsp; In the help file the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/polyline.htm#S2_GUID-FC2C3085-2C89-4CDB-985B-DFE78118B603" target="_self"&gt;arcpy polylines take arrays of points when constructing a polyline&lt;/A&gt;. I was expecting to find the reverse of the&amp;nbsp;&lt;SPAN&gt;WKB property on a polyline?&amp;nbsp; It seems to me that arcpy allows you to convert from a polyline into alternative ways of recording geometry (json, wkb, wkt) but does not seem to consume them?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 09:45:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272354#M67252</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-03-28T09:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently convert a shapely linestring back into an arcpy polyline?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272363#M67254</link>
      <description>&lt;P&gt;arcpy has &lt;A href="https://pro.arcgis.com/de/pro-app/latest/arcpy/functions/fromwkb.htm" target="_self"&gt;FromWKB()&lt;/A&gt; and &lt;A href="https://pro.arcgis.com/de/pro-app/latest/arcpy/functions/fromwkt.htm" target="_self"&gt;FromWKT()&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.InsertCursor(new_fc, ["SHAPE@"]) as cursor:
    new_geom = arcpy.FromWKB(line.wkb)
    cursor.insertRow([new_geom])&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Mar 2023 10:23:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272363#M67254</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-28T10:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to efficiently convert a shapely linestring back into an arcpy polyline?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272364#M67255</link>
      <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;Awesome! It never occurred to me that it would be a function of arcpy, I was looking for some sort of read/write property of a geometry.&amp;nbsp; Well you have definitely earned yourself a&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beer_mug:"&gt;🍺&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for your swift reply.&lt;/P&gt;&lt;P&gt;Duncan&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 10:43:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-efficiently-convert-a-shapely-linestring/m-p/1272364#M67255</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-03-28T10:43:43Z</dc:date>
    </item>
  </channel>
</rss>

