# Moving GPS Points with a VB script - Bearing works well but distance is wrong

I am using a script I found online created in 2003 by one of the commentators here. It is a great script and exactly what I have been looking for and I'm very glad to have found it. It simply takes a points file and using two fields in the table, bearing and distance it moves the points based on these two fields. When I run it, the points always seem to move to the correct bearing but the distances are never correct. For example, I may need to move a point 30 meters away from the original position at a bearing of 85 degrees. The points move much more than that (hundreds of kilometers or more). Is this a projection issue? When I enter 30 in my table as my distance, do some projections interpret this as 30 degrees? How do I get ArcMap to recognize that this is 30 meters? If I can solve this I will be extremely happy. My points file covers very large sections of geography covering many states. Thank you

The script is below

``````Option Explicit
Sub MovePoints()
' move points in layer(0) based on bearing and distance
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

Dim pFLayer As IFeatureLayer
Set pFLayer = pMxDoc.FocusMap.Layer(0)

Dim pFCur As IFeatureCursor
Set pFCur = pFLayer.FeatureClass.Search(Nothing, False)

Dim lBFld As Long, lDFld As Long
lBFld = pFCur.FindField("Bearing")
If lBFld = -1 Then
Exit Sub
End If

lDFld = pFCur.FindField("Distance")
If lDFld = -1 Then
Exit Sub
End If

Dim pFeat As IFeature
Set pFeat = pFCur.NextFeature
Do Until pFeat Is Nothing
Dim pConstPoint As IConstructPoint
Set pConstPoint = New Point
Dim dAngle As Double, dDist As Double, PI As Double
PI = Atn(1#) * 4
dAngle = Azi2Cart(pFeat.Value(lBFld)) * PI / 180
dDist = pFeat.Value(lDFld)
pConstPoint.ConstructAngleDistance pFeat.ShapeCopy, _
dAngle, _
dDist
' maybe set distance to 0 here
' to avoid moving it again
'pFeat.Value(lDFld) = 0
Set pFeat.Shape = pConstPoint
pFeat.Store
Set pFeat = pFCur.NextFeature
Loop
Dim pAV As IActiveView
Set pAV = pMxDoc.FocusMap
pAV.Refresh
End Sub

Function Azi2Cart(ByVal dCompassAngle As Double) As Double
Azi2Cart = -dCompassAngle + 90
End Function
``````
• I'd have thought that the tables units was set to degree's. If you want to make sure you are working in a specific unit, either set the table to it, or find out what the table is using and then covert the amount you want to move, to that unit. – Hairy Oct 17 '11 at 11:30