Skip to content

Instantly share code, notes, and snippets.

@johnbaums
Created March 2, 2022 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbaums/b229e01608dfa9afce9a80f010a7d4fd to your computer and use it in GitHub Desktop.
Save johnbaums/b229e01608dfa9afce9a80f010a7d4fd to your computer and use it in GitHub Desktop.
Convert coords from DMS to Decimal Degrees
dms2dd <- function(x) {
dms <- strsplit(x, '[^0-9.]+')
sapply(dms, function(x) {
sum(as.numeric(x)/c(1, 60, 3600)[seq_along(x)])
})
}
dms2dd(c('34°53’07”S', '138°36’40”E', '138.61111', '34°53’'))
## [1] 34.88528 138.61111 138.61111 34.88333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment