Calculate distance along line

2847
6
Jump to solution
07-03-2022 05:34 AM
kradijaf
New Contributor III

Got a layer containing a single interpolated line (has Z-coordinate) and a layer of points laying on the line. I want to calculate distance from beginning of the line to each point. The optimal solution would be to have the 3D distance between the line beginning and specific point as an attribute in the output table of feature layer, shp etc.

 

Any ideas how to do this?  

0 Kudos
1 Solution

Accepted Solutions
RPGIS
by
Occasional Contributor III

You would have to use geometry objects in order to create the lines that you are looking for. The solution you are looking for sounds like it would require a process below (or close to) if you were to code it for that particular task. There might be a combination of tools that can help you achieve this process, but it can be hard coded as well.

  1. Get the start and end vertices of each line and get their x and y coordinates(you can read up on geometry objects here)
  2. Use a while loop for each line and convert each start and end vertices to xy coordinates.
  3. Get the xy coordinates for each point that falls on the line (may require mathematical calculations to see if the point is between the lines (basically algebra)). Skip the algebra if you are simply looking to create lines based on those points.
  4. Create an array using the start xy coordinate and the closest point coordinate as the end coordinate.
  5. Use the write geometries to convert array of coordinates to line.
  6. Insert newly created line as record into whichever feature class.
  7. Repeat process and break when both start and end xy coordinates match the original line.

There might be more steps than what I am thinking and other tools but @DanPatterson knows more than I do.

View solution in original post

6 Replies
DanPatterson
MVP Esteemed Contributor

Split Line At Vertices (Data Management)—ArcGIS Pro | Documentation

Feature Vertices To Points (Data Management)—ArcGIS Pro | Documentation

should give you the x,y and z values and you can calculate interpoint distances from those values in 2d or 3d


... sort of retired...
kradijaf
New Contributor III

@DanPatterson wrote:

Split Line At Vertices (Data Management)—ArcGIS Pro | Documentation

Feature Vertices To Points (Data Management)—ArcGIS Pro | Documentation

should give you the x,y and z values and you can calculate interpoint distances from those values in 2d or 3d


Thank you. 

How exactly may I calculate the interpoint distance among line after using those two functions?

0 Kudos
DanPatterson
MVP Esteemed Contributor

split line at vertices will result in 2 point line segments.  The shape_length is the distance


... sort of retired...
0 Kudos
kradijaf
New Contributor III

Thought of that solution too, thanks.

 

Need to create lines along the original line so each line starts at the original line´s start and is 1 vertex along the original line longer than last, eg.: 1st new line = 1st - 2nd vertex, 2nd new line = 1st, 2nd, 3rd vertex, 3rd new line = first 4 vertices, ..., last new line = same as original line. Can calculate length of those after I generate them using calculate geometry - Length (3D), need a way to create those lines.

0 Kudos
DanPatterson
MVP Esteemed Contributor

You would have to code it, selecting based on the original ID value, then performing a cumulative sum of the distance/length values


... sort of retired...
0 Kudos
RPGIS
by
Occasional Contributor III

You would have to use geometry objects in order to create the lines that you are looking for. The solution you are looking for sounds like it would require a process below (or close to) if you were to code it for that particular task. There might be a combination of tools that can help you achieve this process, but it can be hard coded as well.

  1. Get the start and end vertices of each line and get their x and y coordinates(you can read up on geometry objects here)
  2. Use a while loop for each line and convert each start and end vertices to xy coordinates.
  3. Get the xy coordinates for each point that falls on the line (may require mathematical calculations to see if the point is between the lines (basically algebra)). Skip the algebra if you are simply looking to create lines based on those points.
  4. Create an array using the start xy coordinate and the closest point coordinate as the end coordinate.
  5. Use the write geometries to convert array of coordinates to line.
  6. Insert newly created line as record into whichever feature class.
  7. Repeat process and break when both start and end xy coordinates match the original line.

There might be more steps than what I am thinking and other tools but @DanPatterson knows more than I do.