Playa

Extending Current Profile\Longsection Python Script

Discussion created by Playa on Mar 10, 2014
Latest reply on Mar 11, 2014 by Playa
I've generated a python script that extracts the points along a proposed pipeline alingment to generate a profile\longesection for our engineers.

Previous Post

'''
Created on Mar 5, 2014

@author: PeterW
'''
import arcpy
import os

# set input and output workspace

pipeline = arcpy.GetParameterAsText(0)
interval = int(arcpy.GetParameterAsText(1))
gdb = arcpy.GetParameterAsText(2)

outpnts = os.path.join(gdb, os.path.join(gdb, os.path.basename(pipeline) + "_pnts"))

# create a list to store the profile points

pts = []

#  use a search cursor to extract the points along the proposed alignment

with arcpy.da.SearchCursor(pipeline, "SHAPE@") as scur:
    for row in scur:
        pts.append(row[0].positionAlongLine(0))
        i = interval
        while i < row[0].length:
            pts.append(row[0].positionAlongLine(i))
            i += interval
        leng = row[0].length
        pts.append(row[0].positionAlongLine(leng))
arcpy.CopyFeatures_management(pts, outpnts)


Currently the output is a point feature class of the points along the proposed alignment based on a defined interval i.e. every 100m with the start and end point added.

What I would like to do is add the chainage\distance as a second field to the points feature class. i.e. firstPoint = 0; secondPoint = 100; thirdPoint = 200 .... lastPoint = 125492.643199m.

Any help in getting started will truly be appreciated.

Regards

Outcomes