Вы можете прочитать значения из файла, используя что-то вроде read.csv
или read.delim
.
Затем, чтобы преобразовать из DDMM.MMMM и DDDMM.MMMM, вы можете использовать что-то вроде этого (конечно, измените по мере необходимости для формы ввода / вывода):
convertISO6709 <- function( lat, lon ) {
# will just do lat and lon together, as the process is the same for both
# It's simpler to do the arithmetic on positive numbers, we'll add the signs
# back in at the end.
latlon <- c(lat,lon)
sgns <- sign(latlon)
latlon <- abs(latlon)
# grab the MM.MMMM bit, which is always <100. '%%' is modular arithmetic.
mm <- latlon %% 100
# grab the DD bit. Divide by 100 because of the MM.MMMM bit.
dd <- (latlon - mm)/100
# convert to decimal degrees, don't forget to add the signs back!
out_latlon <- (dd+mm/60) * sgns
return(out_latlon)
}