Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

enter image description here

I have a layer containing a vector 'Line 1', that originates at point 'A' on a second layer. I also have point 'B' on a third layer. I want to create 'Line 2' that has the same angle and length of 'Line 1', but originates from point 'B'. And I want to repeat this for all vectors on the layer containing 'Line 1'.

i'm working with ArcGIS Engine 10 for .NET. I'm open to solutions working with just ArcGIS 10, so I can create the same geoprocessing tool in ArcGIS Engine.

share|improve this question
From your diagram I am not clear exactly how you want to snap, and you don't mention your license level, but if you have ArcEditor or ArcInfo then the Snap tool may be worth looking at:… – PolyGeo Jun 18 '12 at 1:43
i've ArcInfo licence, but the snapping that i'm trying to make, i think couldn't be done using this tool only. – geogeek Jun 18 '12 at 6:41
up vote 1 down vote accepted

I have made an ArcPy code to virtually snap the lines, so the script calculates the bearing of the lines, snaps the origin of the vector, then build new lines from new snapped points using the bearing.

But I have noticed a weird error using the function BearingDistanceToLine_management in ArcPy. It adds an angle to the bearings. Without understanding the cause of the error, I have eliminated the difference by 180 - 57.935

import arcpy

#arcpy.AddField_management("directions" , "bearing" , "FLOAT" )

arcpy.CalculateField_management("directions" , "bearing" , "180 - 57.935 + math.atan2(( !Shape.firstpoint.X! - !Shape.lastpoint.X! ),( !Shape.firstpoint.Y! - !Shape.lastpoint.Y! ) ) * (180 / math.pi)" , "PYTHON_9.3")

arcpy.Snap_edit("borne" ,  [["D_GPS", "VERTEX", "5"]] )

arcpy.MakeFeatureLayer_management("borne" , "borne_join")
#arcpy.AddField_management("borne_join" , "X" , "DOUBLE" )
#arcpy.AddField_management("borne_join" , "Y" , "DOUBLE" )

arcpy.CalculateField_management("borne_join" , "X" , "!Shape.lastpoint.X!" , "PYTHON_9.3")
arcpy.CalculateField_management("borne_join" , "Y" , "!Shape.lastpoint.Y!" , "PYTHON_9.3")

#arcpy.AddField_management("borne_join" , "distance" , "SHORT" )
arcpy.CalculateField_management("borne_join" , "distance" , "5" , "PYTHON_9.3")

arcpy.MakeFeatureLayer_management("directions" , "dir_join")

arcpy.AddJoin_management("dir_join" , "borne_id" , "borne_join" , "id" )

arcpy.BearingDistanceToLine_management("dir_join" , "new_dir" , "sde.sde.borne.X" , "sde.sde.borne.Y" , "sde.sde.borne.distance" , "METERS" , "sde.sde.directions.bearing" , "DEGREES"  , "GEODESIC" )

share|improve this answer
for more detail concerning the errors in this script here is a question for this problem – geogeek Jun 20 '12 at 21:47

Your Answer


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.