Created
July 25, 2019 20:17
-
-
Save noqqe/31cc19777436f98f31e8bccfaadcbb42 to your computer and use it in GitHub Desktop.
This file contains 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
#53 deg 54' 1.50" N - 27 deg 33' 4.92" E | |
# sexagonial 2 dezimal | |
lonsex2dec <- function(degree, minute, second) { | |
declon <- degree + (minute / 60) + (second / 3600) | |
return(declon) | |
} | |
# test dataframe mit deinen daten | |
x <- data.frame( | |
lat = c('53 deg 54\' 1.50" N', '52 deg 54\' 1.50" N'), | |
lon = c('28 deg 33\' 4.92" E', '27 deg 33\' 4.92" E'), | |
stringsAsFactors=FALSE | |
) | |
# konvertiert werte von xxx deg 23" 23' zu xxx 23 23 | |
fixstr <- function(l) { | |
z <- strsplit(l, " ") | |
n1 <- as.numeric(z[[1]][1]) | |
n2 <- as.numeric(sub('\'', '', z[[1]][3])) | |
n3 <- as.numeric(sub('\"', '', z[[1]][4])) | |
return(c(n1, n2, n3)) | |
} | |
# fuellt dataframe werte in sexadiognal konverter | |
for (i in 1:length(x$lat)) { | |
z1 <- fixstr(x$lat[i]) | |
z1 <- lonsex2dec(z1[1], z1[2], z1[3]) | |
z2 <- fixstr(x$lon[i]) | |
z2 <- lonsex2dec(z2[1], z2[2], z2[3]) | |
print(c(z1,z2)) | |
} | |
# testaufrufe | |
lonsex2dec(degree = gsub(x$lat[0]), minute = 54, second = 1.50) | |
lonsex2dec(degree = 27, minute = 33, second = 4.92) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment