Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

ArcPy: Polyline Geomtry

$
0
0
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:

Code:

>>> 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:

Code:

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

Viewing all articles
Browse latest Browse all 2485

Trending Articles