I am trying to convert polygons to polylines in ArcGIS Pro using ArcPy. I do not have the license so I cannot use the tools that do the job. Due to the way things are set-up for now I cannot use QGIS or GRASS GIS modules. I am basically restricted to ArcPy and would prefer not to use other modules that have to be installed / imported to ensure functionality across different working stations.
The manual workflow as provided by Esri: https://support.esri.com/en/technical-article/000018461
I cannot find a way to populate my newly created Polyline feature with the data from the Polygons.
My function so far (I work with shapefiles):
def PolygonToLine(inFC, outPath, outFC_Name):
# Set local variables
geometry_type = "POLYLINE"
template = inFC
has_m = "DISABLED"
has_z = "DISABLED"
# Use Describe to get a SpatialReference object of input
spatial_reference = arcpy.Describe(inFC).spatialReference
#Execute CreateFeatureclass
arcpy.CreateFeatureclass_management(outPath, outFC_Name, geometry_type, template, has_m, has_z, spatial_reference)
#initiate output (note; shapefile)
outFC = outPath+"/"+outFC_Name
#populate Polyline feature class
arcpy.Copy_management(inFC, outFC)
The result of this is just a copy of my polygon features and an empty Polyline feature dataset. Any ideas?
Polygon.boundary()
request.arcpy.da.SearchCursor()
and list comprehension to create a list of your polygon geometries, and then usearcpy.da.InsertCursor()
to read that list andPolygon.boundary()
to write the polygon boundaries as polylines.