2

I have a polyline, that I wish to create points along using ArcMap 10.2.2. I used the methodology suggested in Creating series of points along polyline?, but I do not seem to be able to generate the points at the set intervals I desire. For instance, densifying the polyline using 500m and 250m, and then converting the vertices to points using the Feature Vertices to Points tool), seems to generate the same number of points (540) for either densifying distance when using the "Both_Ends" option in the Feature Vertices to Points tool:

250m - Both Ends:

enter image description here

500m - Both Ends:

enter image description here

With the same number of points in each generated points layer. And using the option 'All' in the Feature Vertices to Points tool generates way too many points (5250):

enter image description here

My end goal is to have points spaces at every 250m or 500m along each branch of this polyline, finally settling on the polyline to point conversion that generates a reasonable number of values.

3
  • Have a look at RivEX it has a tool that would generate points every _X_m starting from the mouth of the river.
    – Hornbydd
    Commented Nov 11, 2015 at 21:17
  • Silly question but, how long are the branches of your network? I presume they are all longer than 250m? Have you confirmed this? If not, then you would expect the results of both your operations to be identical. Also, what are the units of the SRS you are using? The distance will be the same units, so if your SRS is in degrees, then you are specifying 250 degrees not 250m as your densification distance. Commented Nov 12, 2015 at 8:12
  • In this one instance, they are all 50km long. And I am a PCS with units of meters.
    – traggatmot
    Commented Nov 12, 2015 at 14:46

2 Answers 2

1

See if you can tweak this a wee bit to suit your purpose

import arcpy, os, traceback, sys
from arcpy import env
env.overwriteOutput = True

infc = arcpy.GetParameterAsText(0)
routeid = arcpy.GetParameterAsText(1)
outOption=arcpy.GetParameterAsText(2)
step = float(arcpy.GetParameterAsText(3))
outp=arcpy.GetParameterAsText(4)
# DERIVE OUTPUT FOLDER FROM OUTPUT FC
# Set workspace
arcpy.env.outputMFlag = "Disabled"
outFolder,theFile=os.path.split(outp)
env.workspace = outFolder
d=arcpy.Describe(infc)
SR=d.spatialReference

try:
    def showPyMessage():
        arcpy.AddMessage(str(time.ctime()) + " - " + message)

    point = arcpy.Point()
    arcpy.CreateFeatureclass_management(outFolder, theFile, "POINT", "", "DISABLED", "DISABLED", SR, "", "0", "0", "0")
    arcpy.AddField_management(theFile, routeid, "TEXT", "", "", 25)
    arcpy.AddField_management(theFile, "CHAINAGE", "DOUBLE")
    # define number of shapes
    result=arcpy.GetCount_management(infc)
    nF=int(result.getOutput(0))
    arcpy.SetProgressor("step", "", 0, nF,1)
    # Create search cursor on input polyline
    curT = arcpy.da.InsertCursor(theFile,["SHAPE@",routeid,"CHAINAGE"])
    with arcpy.da.SearchCursor(infc, ("SHAPE@",routeid)) as rows:
        for feat,theID in rows:
            theLength=feat.length
            m=int(theLength/step)
            if outOption=="Chainage":
                Chainages=[]
                for i in xrange(m+1):
                    dL=step*i
                    Chainages.append(dL)
                Chainages.append(theLength)
            elif outOption=="Ends":
                Chainages=[0, theLength]
            elif outOption=="Middle":
                Chainages=[theLength/2]
            for aL in Chainages:
                theP=feat.positionAlongLine (aL)
                point.X=theP.firstPoint.X
                point.Y=theP.firstPoint.Y
                pnt=arcpy.PointGeometry(point,SR)
##                theRow=(theP,theID,aL)
                theRow=(pnt,theID,aL)
                curT.insertRow(theRow)
            arcpy.SetProgressorPosition()
    del rows, curT


except NameError, theMessage:
    arcpy.AddMessage (theMessage)
except:
    message = "\n*** PYTHON ERRORS *** "; showPyMessage()
    message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
    message = "Python Error Info: " +  str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()

Parameters:

enter image description here

enter image description here

2
  • The PointGeometry object returned from positionAlongLine has the same coordinate system as the line, which means it can be passed directly into the insert cursor as is. Edit: I see that you commented out theRow, so I'm curious now.
    – Paul
    Commented Nov 12, 2015 at 0:59
  • @Paul you are right, it will work. When I've made it a while ago, I saw points sitting slightly out of line, I thought it's something to do with coordinate system, turned out to be FGDB settings. Never bothered to update because it works great. It took ESRI a long long time to implement readily available things in ArcView 3....
    – FelixIP
    Commented Nov 12, 2015 at 1:11
0

I found this users tool worked perfectly:

https://gis.stackexchange.com/a/162339/28864

It was the only solution I could get to work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.