1 Reply Latest reply on Feb 22, 2011 8:08 PM by niklas.norrthon-esri-se-esridist

    Converting DMS to DD in this format: DD MM SS.SSSS N/S

    jacobne
      Hi,

      I know this question has been beat to death but I've really struggled with this format.  I have some 5,000 coordinates in this format (ex. 75 25 10.1234 N) and I want to convert them to DD so I can work with the data in ArcMap 10.  Plus, I'm continuing to accumulate additional coordinates so ultimately I'd like to automate the conversion via python.  Any suggestions?  Or could anyone point me to some sample code I could get started with? 

      I've experimented with some of the geoprocessing tools in ArcToolbox but not luck so far. 

      Thanks in Advance,
      Nick
        • Re: Converting DMS to DD in this format: DD MM SS.SSSS N/S
          niklas.norrthon-esri-se-esridist
          Maybe Convert Coordinate Notation (Data Management) if you have ArcGIS 10.

          The following function converts one coordinate on your sample format:
          def parse_latlong_string(coord):
              parts = coord.split()
              # Add error handling here if necessary
              d = int(parts[0])
              m = int(parts[1])
              s = float(parts[2])
              hemisphere = parts[3]
          
              if hemisphere.upper() not in ('NSWE'):
                  raise ValueError('Unknown hemishpere')
          
              dd = d + m/60 + s/3600
                        
              return dd