# Determining distance on line of point, given measure?

I need to determine into a standalone python script the distance of a point on a polyline with M-values and its' coordinates, at a specific measure.

For example, I have to calculate the X,Y of a point situated at measure 12.345 on a polyline with the measures from 10 to 15 and considering that the startpoint of the polyline has m=10

What I did so far was to use the `.positionAlongLine` method, with the distance= 12.345-10, which in field calculator of the polyline featureclass would look like:

``````!Shape!.positionAlongLine(2.345,False).Centroid.x
``````

The problem is that the resulted point with the calculated XY is not exactly at measure 12.345 and not at the distance 2.345 towards the startpoint, as expected.

• I'm not aware of a tool for this, but I haven't had an opportunity to work with 'measure' data so my knowledge on this subject is a little limited. You might need to go down to the vertex level until you find point1.m < value and point2.m > value then measure along that segment (value - point1.m) using Pythagorean calculation. In a feature class that has measures it is my understanding that the vertices also have measure as a property. Commented Nov 13, 2017 at 21:51
• What does your Python script look like so far? You seem to have shown something from the Python Parser of the ArcGIS Field Calculator but nothing of your "standalone python script".
– PolyGeo
Commented Nov 15, 2017 at 5:23
• @MichaelStimson , you gave me a great tip for solving what I needed. I'll explain in in the original post. Commented Nov 17, 2017 at 18:07
• It is not against policy to answer your own question (in fact, it's encouraged). It is, however against policy to place the answer in the question. Commented Nov 17, 2017 at 22:21
– PolyGeo
Commented Nov 20, 2017 at 21:55

What I actually needed was to get two pairs of XY coordinates to calculate the orientation of a segment [P1,P2] that contains a specific measure, where P1 and P2 are two points situated on a polyline feature, at measures m1 and m2.

Solution for my actual problem: Instead of using the distance on the line of a point at a specific measure, I determined the segment (formed by two vertices) on that polyline that containes that measure. In the end,I calculated the orientation of that segment by using the coordinates of the two vertices.

``````# Create a dictionary to store for each point the IDs of the corresponding polyline feature and the "meas" value
d_meas={}
cursor=arcpy.da.SearchCursor(ProjectedRouteEvents,["NEAR_FID","OID@", "MEAS"])
for row in cursor:
if row[0] not in d_meas:
d_meas[row[0]]=[[row[1],row[2]]]
else:
d_meas[row[0]].append([row[1],row[2]])
del cursor, row

d_arg={} #Dictionary that stores the orientation of the polyline at specific measure
cursor=arcpy.da.SearchCursor(polylineFeat, ["OID@","SHAPE@"])
for row in cursor:
if row[0] in d_meas:
s=0
for obj in d_meas[row[0]]:
measure=d_meas[row[0]][s][1]
for vertex in range(row[1].pointCount-1):
array1=row[1].getPart()
pnt=array1.getObject(0).getObject(vertex)
pnt2=array1.getObject(0).getObject(vertex+1)
if pnt.M < measure and pnt2.M > measure:
Xl=pnt.X
Yl=pnt.Y
Xu=pnt2.X
Yu=pnt2.Y
elif pnt.M > measure and pnt2.M < measure:
Xl=pnt2.X
Yl=pnt2.Y
Xu=pnt.X
Yu=pnt.Y
else:
pass
d_arg[d_meas[row[0]][s][0]]=round(orientation(Xl,Yl,Xu,Yu),4)
s+=1
``````