I would like to create perpendicular lines from pointpoints 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´m not advanced in Python. 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""distanceTo" method from point feature to line feature, but I was unable to aquire XY 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