HOW TO
Instructions provided describe the steps to convert point data in degrees, minutes and seconds (DMS) to a shapefile using a Python script in ArcMap.
Warning: The instructions in this article apply only to ArcGIS Desktop version 10 and later versions. For the equivalent process in earlier versions, refer to How To: Convert a file with coordinates in degrees, minutes and seconds to a shapefile using ArcMap.
Note: ArcMap is in Mature support and will be retired March 1, 2026. There are no plans for future releases of ArcMap, and it is recommended that you migrate to ArcGIS Pro. See Migrate from ArcMap to ArcGIS Pro for more information.
80 37 40.86,35 00 48.75 80 37 20.55,35 01 42.35 80 37 55.23,35 01 12.80
-80 37 40.86,35 00 48.75 -80 37 20.55,35 01 42.35 -80 37 55.23,35 01 12.80
LongDMS,LatDMS -80 37 40.86,35 00 48.75 -80 37 20.55,35 01 42.35 -80 37 55.23,35 01 12.80
Note: Any field name can be used, but the name must not be over ten characters long and must not contain spaces or special characters.
ID,LongDMS,LatDMS 1,-80 37 40.86,35 00 48.75 2,-80 37 20.55,35 01 42.35 3,-80 37 55.23,35 01 12.80
def Convert(sField):
sDMS = sField
if len(sDMS.strip())==0:
dDD=0
else:
iDec = 0
iNum= 0
sPre="+"
sDMSNum=""
for i in range(0,len(sDMS)):
sS=sDMS[i:i+1]
if not sS.isalnum():
if sS==".":
if not iDec==0:
bReplace=1
else:
bReplace=0
elif sS=="-":
sPre="-"
bReplace=1
else:
bReplace=1
if bReplace==1:
if iNum<=0:
sDMSNum=sDMS.replace(sDMS[i],"")
elif iNum>0 and sPre=="+":
sDMSNum=sDMS
else:
iNum=iNum+1
sList=sDMSNum.split(" ")
if len(sList)==0:
sDMSNum=sList[0]
iLen=len[sDMSNum]
if iLen>=4:
dS=float(sDMSNum[iLen-1,iLen+1])
dM=float(sDMSNum[iLen-3,iLen-1])
sDMSNum = sDMSNum[0,iLen - 4]
if (Len(sDMSNum) > 2):
dD = float(sDMSNum[-4, -1])
elif (Len(sDMSNum) == 0):
dD = 0
else:
dD = float(sDMSNum)
else:
dDD=0
dDD=dD+dM/60+dS/3600
else:
j=0
dD=0
dM=0
dS=0
for i in range (0, len(sList)):
if j==0:
dD=float(sList[i])
j=j+1
elif j==1:
dM=float(sList[i])
j=j+1
elif j==2:
dS=float(sList[i])
j=j+1
dDD=dD+dM/60+dS/3600
if dDD<-180 or dDD>180:
dDD=0
if sPre =="-":
dDD=dDD*-1
return dDD
__esri_field_calculator_splitter__
Convert ( "ChangeFieldNameHere" )
Article ID: 000012749
Get help from ArcGIS experts
Start chatting now