Playa

ArcPy: Polyline Geomtry

Discussion created by Playa on Aug 3, 2013
Latest reply on Aug 6, 2013 by Playa
I'm busy writing a script to generate long-sections from a polyline. I've written the following based on an example from an ESRI video. The problem that I have is that the first and last position is not returned.

The following works but doesn't return the first and last position along the polyline:

>>> pts = []
>>> with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers", "SHAPE@")as rows:
...     for row in rows:
...         i = 100
...         while i < row[0].length:
...             pts.append(row[0].positionAlongLine(i))
...             i += 100
... arcpy.CopyFeatures_management(pts, r"in_memory\ptsalongline")


I've tried the following but returns an error:

>>> pts = []
>>> with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers", "SHAPE@") as rows:
...     for row in rows:
...         pts.append(row[0].firstPoint)
...         i = 100
...         while i < row[0].length:
...             pts.append(row[0].positionAlongLine(i))
...             i += 100
...         pts.append(row[0].lastPoint)
... arcpy.CopyFeatures_management(pts, r"in_memory\Ptsalongline")


Any help will be appreciated.

Regards

Outcomes