There is probably a way to do this, but I can't find a way to transform a GPS DMS format to degree decimal in R.

e.g. from GPS coordinate, see below, is there a way to transform this in R?

gps.coord <- "S0 44.437 W90 18.131"

The format is GPS: [N,S] dd mm.mmm [W,E] dd mm.mmm

This is the way I made it! (There is probably a better way)

lat = - as.numeric(substr(gsub(pattern = "S0 ",
                               replacement = "",gps.coord),
                          start = 0,stop = 6))/60
lat.dd = lat - as.numeric(substr(gps.coord,2,3))
lon = - as.numeric(substr(gsub(pattern = "S0 ",
                               replacement = "",
                          start = 12,stop = 18))/60
lon.dd = lon - as.numeric(substr(gps.coord,12,13))

Decimal Degrees (WGS84)

Latitude    Longitude
-0.740617   -90.302183

Degrees, Minutes & Seconds

Latitude    Longitude
S0 44 26    W90 18 07


Latitude    Longitude
S 0 44.437  W 90 18.131


X   Y
15S 800286  9918048

I'm looking for something like this site where from one input, you get different possible output.

  • In your case is string work; you have to either divide the latter part by 60, extracting the minute part using str_split; for western longitudes you must use -abs(), that's the way spatial packages understand west; there's the function sp::char2dms() %>% sp::as.numericDMS() which takes a string in the format degrees minutes seconds with separators, which would require you to convert the latter part to seconds and then put separators between numbers. – Elio Diaz Jun 18 '18 at 20:27
  • Converting decimal degrees to decimal minutes or degrees-minutes-seconds is basic algebra. Adding in the UTM changes this into multiple questions (and failure to specify which zone makes this 60 locations). – Vince Jun 18 '18 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.