Determining whether point is on left or right side of road using ArcPy? [closed]

Is there any way to determine the left or right side of road using arcpy? I was able to find if road is going from north to south,south to north,east to west or west to east.link that helped:- How to determine right side of the street vs left side?.But still this do not identify the sides on which the point lies.

I am using ArcPy from ArcGIS for Desktop with a Basic level license.

closed as off-topic by PolyGeo♦Jul 11 '16 at 9:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

You can use geometry tokens and the queryPointAndDistance function to determine whether a point falls on the right hand-side of a line or not. Right/Left is determined by the digitized direction of the line.

try this:

``````pnt = [x[0] for x in arcpy.da.SearchCursor("point",["SHAPE@"])][0]
line = [x[0] for x in arcpy.da.SearchCursor("line",["SHAPE@"])][0]
line.queryPointAndDistance(pnt)

#output
(<PointGeometry object at 0x27b71d30[0x27b71860]>, 178.62560415967232, 19.598416635825153, False)
``````

the tuple above gives you:

• A PointGeometry that is the nearest point on the polyline to the in_point.
• The distance between the start point of the line and the returned point on the line.
• The minimum distance between the line and the in_point.
• A Boolean that indicates if the in_point is on the right side of the line. The direction of the line determines the right and left sides.

EDIT

Building on the above, here is an example..

For the points and lines shown above, the code below

``````import itertools
import arcpy
#create dictionaries for pnts and lines - object id as key and geometry as value
lines = dict([(l[0],l[1]) for l in arcpy.da.SearchCursor("streets",["OBJECTID","SHAPE@"])])
pnts = dict([(p[0],p[1]) for p in arcpy.da.SearchCursor("pnts",["OBJECTID","SHAPE@"])])
#evaluate each point against each line
for pl in itertools.product(pnts,lines):
pntID = pl[0]
lineID = pl[1]
output = lines[lineID].queryPointAndDistance(pnts[pntID])
print "\nPoint {0} is:\n{2}m from line {1}. \non the right side of line {1}: {3}".format(pntID,lineID,round(output[2],2),output[3])
``````

produces