I would like to create perpendicular lines from points to line, similar to this:
I have ArcGIS 10.1, so "queryPointAndDistance" doesn´t work for me, and basic licence level, so I can´t use "Generate Near Table" neither.
I thought about following approach:
- Coordinates X1Y1 are known (coordinates of the point feature)
- acquire X2Y2 coordinates of the closest point on the line segment
- create line feature from X1Y1 to X2Y2
- new line feature is perpendicular to existing line
I tried to use "distanceTo" method from point feature to line feature, but I was unable to aquire coordinates of the closest point of the line segment (X2Y2), which should be used during "distanceTo" method.
Is it possible to get coordinates of the closest point on the line segment from "distanceTo" method or should I use another approach?
point_feature = "points_select"
line_feature = "line_select"
pointcursor = arcpy.da.SearchCursor(point_feature, ['SHAPE@'])
for row in pointcursor:
geometry = pointcursor[0]
linecursor = arcpy.da.SearchCursor(line_feature, ['SHAPE@'])
for row in linecursor:
newgeometry = linecursor[0]
dist = newgeometry.distanceTo(geometry)
print dist
Best Answer
It took below script 3 seconds to find 100 nearest points on the line. It uses positionAlongLine method on geometry which I believe available in 10.1
SCRIPT:
OUTPUT:
I hope script is documented well enough to understand naming conventions and must have field.