[R] GPS handling libraries or (String manipulation)
Justin Haynes
jtor14 at gmail.com
Wed Mar 7 17:39:17 CET 2012
Take a look at:
http://cran.r-project.org/web/views/Spatial.html
But I've always just parsed the string...
This is from the last time I did this, its not quite the same but you
can see the similarities.
## if data is presented as 43°02'46.60059" N need to split on the °
symbol, ' and ".
to.decimal <- function(vec){
# convert all symbols to _
vec <- gsub('°','_',vec)
vec <- gsub('\'','_',vec)
vec <- gsub('\"','_',vec)
split <- str_split(vec,'_')
deg <- as.numeric(sapply(split,'[',1))
min <- as.numeric(sapply(split,'[',2))
sec <- as.numeric(sapply(split,'[',3))
deg <- deg + min/60 + sec/3600
return(deg)
}
On Wed, Mar 7, 2012 at 8:28 AM, Alaios <alaios at yahoo.com> wrote:
> Dear all,
> I would like to ask you if R has a library that can work with different GPS formats
>
> For example
> I have a string of this format
>
> N50° 47.513 E006° 03.985
> and I would like to convert to GPS decimal format.
>
> that means for example converting the part N50° 47.513
> to 50 + 47/60 + 513/3600.
>
> Is it possible to do that with R?
> What is the name of such a library?
>
> I would like to thank you in advance for your help
>
> B.R
> Alex
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list