Points along Polyline

1751
9
10-25-2011 07:15 AM
BradFuller
New Contributor
Is there a Python script out there that will place points along a polyline at a preset distance (inputed). It would be great if the script would also not allow a point at the end of the line as well as not placing a point unless the distance is avalible to the end of the line. Such as if your request is every 525ft it would place a point at the start, places a point every 525ft there after. unless there is not a complete 525ft left before the end of the line than there is no point placed.

Brad
Tags (2)
0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus
Density at
http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=C466543F-1422-2418-8843-D333B...
but you will always have the end point, so you can modify the code or deal with it in some other way
0 Kudos
ChrisSnyder
Regular Contributor III
Densify is now also available "out of the box" at v10 (ArcEditor and above license levels). Use the FeatureToVerticiesPoint tool to sort out what vertices belong to the original layer and which ones were created through the densifying process. A text field consisting of concatenated X and Y coordinates makes a convenient "key field" for doing the comparison.
0 Kudos
DanPatterson_Retired
MVP Emeritus
I will add that Densify is available at the ArcView license ... (continueing my venture to have all useful tools available and remove the need for different license levels 🙂 )
0 Kudos
ChrisSnyder
Regular Contributor III
Sounds like a socialist conspiracy to undermine American capitalism...

:cool:
0 Kudos
KimOllivier
Occasional Contributor III
You could use Linear Referencing. Build the polylines for routes, (CreateRoutes) and then add a table with a measure at the chosen interval. This will create a set of points along the route (and will not add one at the end for an odd remainder).
You will have to create a dummy table with n x interval records that exceed the likely number. Does that disqualify the method because the easiest way to do that is run a python script to build a dummy table? But you only have to do it once. It can be reused.
Trying to think of everything, if you want to add points at a lot of different polylines, each one has to be a separate route ID.

def makeEvent(event):
    ''' Creates a table of events
    using fields plot and mark as a composite key plotmark
    all fields hardcoded:
        sampling_location
        plotmark
        plotid
        mark
        transect
        distance_along_transect
        fpc_number
    '''
    try:
        curIn = arcpy.InsertCursor(event)
        for row in arcpy.SearchCursor(routeFC):
            plotmark = row.plotmark
            plotid = row.plotid
            mark = row.mark
            for pt in range(1,traps+1): # one-based counting
                rownew = curIn.newRow()
                rownew.sampling_location = plotid # field Increased
                rownew.transect = mark.strip()
                rownew.trap_number = int(pt)
                rownew.distance_along_transect = int(pt*spacing) # long??
                rownew.plotmark = plotmark
                curIn.insertRow(rownew)
        del curIn
        del rownew
        del row
        countrow = str(arcpy.GetCount_management(event))
        arcpy.AddMessage(event+" "+countrow)
        return None
0 Kudos
BradFuller
New Contributor
Dan, when I add your script to a toolbox I get a "This tool has no parameters" message when I activate the script. As I am not a script guru, do you have any thoughts.
Brad
0 Kudos
BradFuller
New Contributor
Kim, while I don't dought that your method will work, I am not that proficent with arcmap. I'm a click on the tool and let it work kind of guy.
However if I get time,
I'm not against giving it a try.
Thanks
Brad
0 Kudos
DanPatterson_Retired
MVP Emeritus
Brad
You right-click on the top of the Arctoolbox tree and select Add Toolbox, I have already created the toolbox and it has the associated parameters etc.  Just make sure that you unzipped the toolbox and its associated scripts in the same folder
0 Kudos
BradFuller
New Contributor
Brad
You right-click on the top of the Arctoolbox tree and select Add Toolbox, I have already created the toolbox and it has the associated parameters etc.  Just make sure that you unzipped the toolbox and its associated scripts in the same folder


Ahh! I see says grasshopper, it is the tool for the toolbox.

Thank you,
Brad
0 Kudos