Skip to content

Gps fraction of degrees function

3 messages · Alaios, Clint Bowman

#
The following (untested) should get you close:

deg<-as.integer(strsplit(coords, "?")[[1]][1])
min<-as.integer(strsplit(strsplit(coords, "?")[[1]][2], 
"'")[[1]][1])
sec<-as.numeric(strsplit(strsplit(strsplit(coords, "?")[[1]][2], 
"'")[[1]][2], "\"")[[1]][1])
nswe<-strsplit(strsplit(strsplit(coords, "?")[[1]][2], 
"'")[[1]][2], "\"")[[1]][2]

deg.frac<-((sec/60+min)/60+deg
deg.frac<-ifelse(nswe=="S"|nswe=="E",-deg.frac,deg.frac)

Clint
#
I see my pre-coffee fingering hit an incorrect key in the final 
line--"E" is positive, "W" is negative.