Skip to main content
4 of 4
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/

You need to break it down to points if they're good points and reconstruct. Polylines are made from paths, polygons are made from rings. Although they are created in a similar way they are not compatable, hence your error.

Go through each point on the line adding a point to your output array and then insert.

here's a post that might help Getting all the points of polyline

This should work, though it's only a fragment... you have to set your own FeatureClass and make an insert cursor to accept the polygon:

rows = arcpy.da.SearchCursor(FeatureClass)
desc = arcpy.Describe(FeatureClass)
shapefieldname = desc.ShapeFieldName

for row in rows:
    feat = row.getValue(shapefieldname) # input line
    PArray = arcpy.Array() # new polygon
    partnum = 0
    for part in feat:
        for pnt in feat.getPart(partnum):
            PArray.add(arcpy.Point(pnt.X,pnt.Y))
        # you will need to check that the first and last point are the same
        partnum += 1
    OutPoly = arcpy.Polygon(PArray) # now it's a polygon

Have a read of these:

Reading Geometries http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001t000000

Writing Geometries http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Writing_geometries/002z0000001v000000/

Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75