Update X,Y coordinates in a shapefile

1259
1
Jump to solution
12-24-2012 06:41 AM
MikeRadko
New Contributor III
I'm searching for a solution to update my x,y coordinates written to my shapefile when a feature is moved.

I am able to use the GPS to autopopulate the x,y fields in my shapefile when a point is initially collected, but there are some instances where we can't physically get close enough to a feature so we adjust (move) the feature on-screen in arcpad to better represent its true location.  However, the x,y coordinates that are stored in the shapefile .dbf are from the original gps location and I need to update those values to the new position.

One thought is to fire off a re-calculation of the x,y attribute fields when a feature is moved.  Or to calculate all x,y point features when arcpad closes.

Anyone out there who may have done this before?

Thanks,

Mike
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MikeRadko
New Contributor III
Here's what I did to update x,y in my shapefile.  I used the onfeaturegeometrychanged event to make a call to my VBScript, which would take my selected position that was moved and re-calc the x,y position.

This is the script:

Option Explicit

Sub CalcXY

Dim objRS, f, numRecs

Set objRS = Map.Selectionlayer.Records
objRS.Bookmark = ThisEvent.Bookmark

For Each f in objRS.Fields
Select Case Ucase(f.name)
  Case "UTM_X"
   f.Value = objRS.Fields.Shape.X
  Case "UTM_Y"
   f.Value = objRS.Fields.Shape.Y
End Select
Next
objRS.Update

End Sub


Mike

View solution in original post

0 Kudos
1 Reply
MikeRadko
New Contributor III
Here's what I did to update x,y in my shapefile.  I used the onfeaturegeometrychanged event to make a call to my VBScript, which would take my selected position that was moved and re-calc the x,y position.

This is the script:

Option Explicit

Sub CalcXY

Dim objRS, f, numRecs

Set objRS = Map.Selectionlayer.Records
objRS.Bookmark = ThisEvent.Bookmark

For Each f in objRS.Fields
Select Case Ucase(f.name)
  Case "UTM_X"
   f.Value = objRS.Fields.Shape.X
  Case "UTM_Y"
   f.Value = objRS.Fields.Shape.Y
End Select
Next
objRS.Update

End Sub


Mike
0 Kudos