Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

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 polylineGetting 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/

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/

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/

added 535 characters in body
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75

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/

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:

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

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/

some code
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75

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:

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

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.

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

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:

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
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75
Loading