Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting GPS data from Decimal Minutes Seconds to Decimal Degrees

    Hi Statalisters,

    I need to convert GPS longitude and latitude data from the Decimal Minutes Second (DMS) format to the Decimal Degrees (DD) format.

    An example of my DMS-coded data is:
    Latitude: 77.30.30 (north), Longitude: 164.45.15 (east).

    The corresponding DD format I need would be:
    Latitude: 77,508333, Longitude: 164,754167.

    I found that the conversion formula is: Decimal Degrees = Degrees + ((Minutes / 60) + (Seconds / 3600)).

    Is there a simple way to carry out this conversion in Stata? I have a large number of observations.

    Many thanks,
    Sophia


  • #2
    Yes, there is, but in detail it depends on exactly what your variables look like. See https://www.statalist.org/forums/help#stata for advice on giving a data example.

    Comment


    • #3
      Thanks for your quick reply Nick. Hope the following data example helps to clarify my question:

      Code:
      * Example generated by -dataex-.
      clear
      input int hhid str9 hh2b str10 hh2c
            
       1 "00.38.065" "034.39.138"
                       
       2 "00.38.594" "034.39.434"
              
       3 "00.38.733" "034.39.679"
             
       4 "-888"      "-888"      
                     
       5 "00.39.065" "034.39.983"
          
       6 "00.37.683" "034.39.011"

      Comment


      • #4
        I am particularly confused by the fact that my GPS variables (hh2b and hh2c) are string variables. Would very much appreciate any help!
        Do let me know in case you have any questions.

        Best,
        Sophia

        Comment


        • #5
          Those look to me like

          longitude and latitude in degrees and decimal minutes -- for perhaps somewhere in Algeria???

          If so, this may help.


          Code:
          * Example generated by -dataex-.
          clear
          input int hhid str9 hh2b str10 hh2c
           1 "00.38.065" "034.39.138"
           2 "00.38.594" "034.39.434"
           3 "00.38.733" "034.39.679"
           4 "-888" "-888" 
           5 "00.39.065" "034.39.983"
           6 "00.37.683" "034.39.011" 
           end 
           
           replace hh2c = subinstr(hh2c, ".", " ", 1)
           split hh2c, destring 
           gen double wanted1 = hh2c1 + hh2c2/60 
           
           list , sep(0) 
           
           
          
          
              +------------------------------------------------------------+
               | hhid        hh2b         hh2c   hh2c1    hh2c2     wanted1 |
               |------------------------------------------------------------|
            1. |    1   00.38.065   034 39.138      34   39.138     34.6523 |
            2. |    2   00.38.594   034 39.434      34   39.434   34.657233 |
            3. |    3   00.38.733   034 39.679      34   39.679   34.661317 |
            4. |    4        -888         -888    -888        .           . |
            5. |    5   00.39.065   034 39.983      34   39.983   34.666383 |
            6. |    6   00.37.683   034 39.011      34   39.011   34.650183 |
               +------------------------------------------------------------+

          Comment


          • #6
            Thanks so much Nick, this worked! Not too bad of a guess...actually Kenya .

            Comment

            Working...
            X