Hi,
I am trying to make a python script that will do the equivalent to that of selecting a point feature editing this and creating "Points along line" with "Varying Distances".
This will give a menu like this one:
Where you will have to plot the distances manually. The next row will indicate the distance relative to the previous point.
I have a lot of points I'd like to plot in and therefore I want the stuff to go automatically.
So far I've had a look into using something like this:
>>> arcpy.GeneratePointsAlongLines_management(line2choose,"pntsAlongLine","DISTANCE",[10,20,10])
The list i've made at the end obviously won't work.
I've also had a look to the possibility of importing an excel file with the ID and Distance columns and creating points from this. If arcpy has a function to add a single point along a line with a specific distance from start I could do a loop and generate all the points from the imported table. So far I haven't found such a function.
Br,
Haakon Haugerud
Hi,
It would be a neat enhancement for the Create Points Along Lines and the Offset editing tools (both found on the Edit ribbon > Modify features pane) to be able to import distance values from a file - currently not possible. However, have you tried the Linear Referencing toolbox (Analysis tab > Tools > look for Linear Referencing Tools). I think the only two geoprocessing tools you would need are Create Routes and Make Route Event Layer.
An overview of the Linear Referencing toolbox—Help | ArcGIS Desktop
These two tutorials are written for ArcMap, but show how to use the above geoprocessing tools:
Exercise 2: Creating and calibrating route data—Help | ArcGIS Desktop
Exercise 4: Displaying and querying route events—Help | ArcGIS Desktop
Hope this helps!
Scott
Thanks Scott.
I am trying to use the Linear Referencing tools now, but have a question.
Right now I am trying to make a Route Event Layer with my Route and an input event table. But I got the error that "ERROR 000840 The value is not a Route Measure Event properties". Trying to find a way to choose that the Field is a route event field, but I am having problems.
I'm not sure about why that could be, but a quick search on Geonet reveals someone who found a solution for their specific case:
https://community.esri.com/thread/101652#comment-658022
If that doesn't work, maybe a quick call to Esri Technical Support will help? - Esri Support Contact Support
Hi,
I am wondering, you had any luck in figuring that out? I also need to create thousands of points along the line at varying (known) distances but unable to find any way of doing that.
Looks like your Route Identifier Field was pointed at a Distance value in attributes of the original polyline used to create the route. It needs to point to a unique route ID that is common to the entire polyline *and* the table of distances you'll use when you display route events. So if you add routeID as an attribute of the polyline before you turn it into a route, and then use that same routeID as an attribute of your table of distances, the two will work together nicely.
If you have a table with the distances down the line in it, you don't need to enter them manually using Create Points Along Line tool.
Create a route from your polyline - https://pro.arcgis.com/en/pro-app/2.9/tool-reference/linear-referencing/create-routes.htm (you'll need to add an attribute for route identifier)
Then add events to your route using that table of distances down the line - https://pro.arcgis.com/en/pro-app/2.9/help/data/linear-referencing/display-route-events.htm (you'll need to include the same attribute value for route identifier that your used on the polyline that you turned into a route in the previous step)
You can take the resulting events layer and export them as points along the polyline.
I know this is a really late response, but I searched for a long time trying to find out how to do this in a way other than entering each point distance one at a time...
Hi all:
I am in the same position as well.
I need to make a point feature class along a line with varying and known distances but unable to find a way to do that. I have also tried using similar approach mentioned a the beginning of this thread and did not make any progress.
Any suggestions please?
Hi,
did you got a solution?
Thanks
import arcpy
# Set up environment settings
arcpy.env.workspace = r"C:\Your\Workspace" # Set your workspace path here
arcpy.env.overwriteOutput = True
# Input polyline feature class
input_polyline = "your_polyline.shp" # Change to your input polyline shapefile
# Output point feature class
output_points = "points_along_polyline.shp" # Change to your desired output point shapefile
# Table containing distances along the line
distance_table = "distance_table.dbf" # Change to the path of your distance table
# Field in the distance table containing the distances
distance_field = "Distance" # Change to the name of your distance field
# Create an empty list to hold point geometries
point_geometries = []
# Iterate through the table and create points at the specified distances
with arcpy.da.SearchCursor(distance_table, [distance_field]) as cursor:
for row in cursor:
distance = row[0]
with arcpy.da.SearchCursor(input_polyline, ["SHAPE@"]) as polyline_cursor:
for polyline_row in polyline_cursor:
polyline = polyline_row[0]
if distance <= polyline.length:
point = polyline.positionAlongLine(distance)
point_geometries.append(point)
# Create a new point feature class and add point geometries
arcpy.CopyFeatures_management(point_geometries, output_points)
print("Points created along the polyline using distances from the table.")
This should work if you want to add points along a polyline by referencing an existing table with all of your distance values. If not, you can copy and paste your values in the following:
import arcpy
# Set up environment settings
arcpy.env.workspace = r"C:\Your\Workspace" # Set your workspace path here
arcpy.env.overwriteOutput = True
# Input polyline feature class
input_polyline = "your_polyline.shp" # Change to your input polyline shapefile
# Output point feature class
output_points = "points_along_polyline.shp" # Change to your desired output point shapefile
# List of distances along the line where you want to place points
distances = [50, 100, 200, 300, 500] # Modify as needed
# Create an empty list to hold point geometries
point_geometries = []
# Iterate through the vertices of the polyline and create points at the specified distances
with arcpy.da.SearchCursor(input_polyline, ["SHAPE@"]) as cursor:
for row in cursor:
polyline = row[0]
for distance in distances:
if distance <= polyline.length:
point = polyline.positionAlongLine(distance)
point_geometries.append(point)
# Create a new point feature class and add point geometries
arcpy.CopyFeatures_management(point_geometries, output_points)
print("Points created along the polyline at varying distances.")
I hope this helps!