Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Here's my situation - I'm working on a project that requires 20,000+ short connector lines be created, each drawn from a point to a snapped location on a nearby polyline such that the resulting connector line is perpendicular to the polyline.

If done with arcpy, this requires a script that can a.) find the nearest polyline, b.) calculate the place on that polyline that will enable a perpendicular line to be created, c.) create temporary coordinates at that location, and d.) create the connector line.

Has anybody tried something like this? What specific commands might be necessary? Thanks in advance for your help.

-Michael

share|improve this question

4 Answers 4

Sorry, got busy at work and couldn't post until now. Below is the script I rolled up from the suggestions.

It strikes me in hindsight that this might also be achieved with an edge snap instead of a near command - it looks like arcGIS basically performs a near command on the snap.

-Michael

import arcpy, os

try:
inPoints = arcpy.GetParameterAsText(0)
nearLines = arcpy.GetParameterAsText(1)
outFC = arcpy.GetParameterAsText(2)
scratchWorkspace = arcpy.GetParameterAsText(3)

# Get the scratch workspace.
#scratchWorkSace = env.scratchWorkspace

# Get the spatial reference of the input
spatialRef = arcpy.Describe(inPoints).spatialReference

# Determine the temporary output feature class path and name
tempFC = os.path.join(scratchWorkspace, "temp")

# Copy input point features to temporary feature class
arcpy.CopyFeatures_management(inPoints, tempFC)

# Add XY coordinates for point features
arcpy.AddXY_management(tempFC)

# Perform Near Analysis
arcpy.Near_analysis(tempFC, nearLines, "", "LOCATION", "NO_ANGLE")

# Create connector line FC using XY To Line
arcpy.XYToLine_management("tempFC", "outFC", "POINT_X", "POINT_Y", "NEAR_X", "NEAR_Y", "GEODESIC", "", "spatialRef")

except Exception, e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "Line %i" % tb.tb_lineno
print e.message
share|improve this answer

If no perpendicular can be drawn within the two end points of a polyline segment then the nearest point is the closer end point. So, this statement is not always true:

"If the line from the point to the "nearest" point along a polyline is not perpendicular to the polyline, then the "nearest" point is incorrect!"

share|improve this answer

Also, you can try the Near command. It will add the closest XY coordinate on the Line FC to the Point FC table. Most of the time this is perpendicular. Run Add XY coordinates to populate the Point xy coords. You can easily create a line connecting the two locations with "XY to Line", new in ArcGIS 10. Shouldn't take too much to test this.

share|improve this answer
    
If the line from the point to the "nearest" point along a polyline is not perpendicular to the polyline, then the "nearest" point is incorrect! –  whuber Oct 18 '11 at 16:12
    
Thanks, everyone, for your quick responses. Armed with the above information, I've gotten everything working. –  Michael Lachman Oct 18 '11 at 16:31
1  
@MichaelLachman, could you post your solution either as an answer or as an update to your question? –  blah238 Oct 18 '11 at 17:21

Take a look at the script linked below. Maybe it will work for you, or maybe you will be able to modify them to fit your needs:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.