[R-sig-Geo] Coordinate interpolation keeping NAs

Karl Ove Hufthammer karl at huftis.org
Wed Aug 29 18:15:56 CEST 2012


Mario A. Pardo skreiv:

> lon <- c(-115.86, -115.83, NA, -115.78, -115.78, -115.75, NA, -115.68,
> -115.66)
> lat <- c(  29.76,   29.61, NA,   29.55,   29.53,   29.41, NA, 29.13,
> 29.09)
> 
> and I need a new set of coordinates c(new.lon, new.lat) with a higher
> resolution, following some interpolation criterium, but keeping the NAs
> where they should be, according to the original data.

For interpolation you could try the ‘makeLine’ function in the ‘geosphere’ 
package, which also takes into account the curvature of the Earth. But I’m 
not sure I understand what the NA values in your example are supposed to 
represent. If they represent breaks in the lines, I would just split the 
vectors before running ‘makeLine’.

-- 
Karl Ove Hufthammer
E-mail: karl at huftis.org
Jabber: huftis at jabber.no



More information about the R-sig-Geo mailing list