Created
March 2, 2022 02:41
-
-
Save johnbaums/b229e01608dfa9afce9a80f010a7d4fd to your computer and use it in GitHub Desktop.
Convert coords from DMS to Decimal Degrees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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