This Field Calculator script will update the SHAPE geometry field in an ArcGIS feature class from Degrees Minutes Seconds latitude and longitude fields. Use within an edit session is recommended.
TO USE:
open the attribute table for a UTM_NAD83 point feature class with latitude and longitude values stored as degrees, minutes and seconds (separate fields in the example), select the SHAPE field
then hit CTRL + SHIFT + F to open the field calculator.
In the field calculator, check the Advanced Option and paste this script in the Pre-Logic VBS Script Code text box.
Make sure that the layer index number for the feature class is set. This item can be found by searching the code below for 'SET THIS.
Type the word pPoint into the bottom text box and hit OK
Empty geometry will be generated for out of range latitude and longitude values.
Dim pSpatialRefFactory As ISpatialReferenceFactory Dim pSpatialRef As ISpatialReference Dim pUTMSR As ISpatialReference Dim pPoint As IPoint Dim Latitude as Double Dim Longitude as Double
Latitude = [LatDeg] + [LatMin] / 60 + [LatSec] / 3600 Longitude = [LongDeg] + [LongMin] / 60 + [LongSec] / 3600 Set pPoint = New Point
if ((abs(Latitude) <=90) and (abs( Longitude) <= 180)) then
pPoint.x = Longitude pPoint.y = Latitude
Set pSpatialRefFactory = New SpatialReferenceEnvironment Set pSpatialRef = pSpatialRefFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984) Set pUTMSR = pSpatialRefFactory.CreateProjectedCoordinateSystem(esriSRProjCS_NAD1983UTM_12N)
Set pPoint.SpatialReference = pSpatialRef pPoint.Project pUTMSR