<?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 Convert shapefile polygons to polylines in Model Builder in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1479860#M83892</link>
    <description>&lt;P&gt;I was wondering if there is a way to automate the following process in Model Builder:&amp;nbsp;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-convert-shapefile-polygons-to-polylines-000018461" target="_blank"&gt;How To: Convert Shapefile Polygons to Polylines (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm stuck on steps 9-14 in the ArcGIS Pro section of the linked page.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have an advanced license for ArcGIS Pro so I don't have access to the Feature to Polyline tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 21:46:20 GMT</pubDate>
    <dc:creator>norcal916</dc:creator>
    <dc:date>2024-05-28T21:46:20Z</dc:date>
    <item>
      <title>Convert shapefile polygons to polylines in Model Builder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1479860#M83892</link>
      <description>&lt;P&gt;I was wondering if there is a way to automate the following process in Model Builder:&amp;nbsp;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-convert-shapefile-polygons-to-polylines-000018461" target="_blank"&gt;How To: Convert Shapefile Polygons to Polylines (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm stuck on steps 9-14 in the ArcGIS Pro section of the linked page.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have an advanced license for ArcGIS Pro so I don't have access to the Feature to Polyline tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 21:46:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1479860#M83892</guid>
      <dc:creator>norcal916</dc:creator>
      <dc:date>2024-05-28T21:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert shapefile polygons to polylines in Model Builder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1480273#M83931</link>
      <description>&lt;P&gt;There's a pretty straightforward way that you could do this with Python, and you could convert it into a script tool as well to use going forward. Although, in my version I work mostly in a GDB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Gathering layer and field info
project = arcpy.mp.ArcGISProject("CURRENT")
mv = project.activeMap
lyr = mv.listLayers("POLY_LAYER_NAME")
desc = arcpy.Describe(lyr)
shape_name = desc.shapeFieldName
oid_name = desc.OIDFieldName
flds = [fld.name.replace(shape_name, "SHAPE@").replace(oid_name, "OID@") for fld in arcpy.ListFields(lyr) if "Shape_" not in fld.name]
shape_index = flds.index("SHAPE@")

#Create Empty Line Feature Class
workspace = lyr.connectionProperties["connection_info"]["database"]
result = arcpy.management.CreateFeatureclass(workspace, f"{lyr.name}_line", 'POLYLINE', lyr)
line_path = result.getOutput(0)

# Get the polygon features and convert to lines
features = [list(row) for row in arcpy.da.SearchCursor(lyr, flds)]
for ftr in features:
    geom = ftr[shape_index]
    ftr[shape_index] = arcpy.AsShape(geom.JSON.replace("rings", "paths").replace("Rings", "Paths"), True)

# Insert new line features into new Line Feature Class
with arcpy.da.InsertCursor(line_path, flds) as cursor:
    for ftr in features:
        cursor.insertRow(ftr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The reason I used the json for the geometry is because this version accounts for multipart features and curves just by changing the "rings" to "paths" and the "curveRings" to "curvePaths".&lt;/P&gt;&lt;P&gt;One other thing is that I did a bit of substitution to change the Shape field to "SHAPE@" and the OBJECTID to "OID@". "Shape@" and "OID@" are keywords for the different cursors and it's easier to work with those so you don't have to worry about the actual name, which can be apparent in the beginning where we get the names from the Describe object.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 15:28:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1480273#M83931</guid>
      <dc:creator>Matthew_Muehlhauser</dc:creator>
      <dc:date>2024-05-29T15:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert shapefile polygons to polylines in Model Builder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1482289#M84041</link>
      <description>&lt;P&gt;Thank you. I tried using the code you provided but I received the following error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 27, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: cannot alter multipart geometry type&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 21:14:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1482289#M84041</guid>
      <dc:creator>norcal916</dc:creator>
      <dc:date>2024-05-31T21:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert shapefile polygons to polylines in Model Builder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1483119#M84065</link>
      <description>&lt;P&gt;Did you end up making any changes to the script? It's hard to tell for sure without seeing your data, but based on the error, my guess is it has something to do with the fields not matching up exactly. I didn't do too much testing myself, so you might just need to try running the below lines and see what it gives you:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;flds = [fld.name.replace(shape_name, "SHAPE@").replace(oid_name, "OID@") for fld in arcpy.ListFields(lyr) if "Shape_" not in fld.name]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And&amp;nbsp; then try comparing it to the result of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[fld.name for fld in arcpy.ListFIelds("Line_Layer_Name")]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep in mind though that this second line doesn't replace the ID or shape fields with the "@" version, so there will be those two differences for sure.&lt;/P&gt;&lt;P&gt;If they are different, then you might need to find a way to account for that.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 11:37:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/convert-shapefile-polygons-to-polylines-in-model/m-p/1483119#M84065</guid>
      <dc:creator>Matthew_Muehlhauser</dc:creator>
      <dc:date>2024-06-03T11:37:40Z</dc:date>
    </item>
  </channel>
</rss>

