Interpolating along an XY path]
Rob Schick wrote:
I have a series of x,y coordinates that represent a movement path of a tagged animal. I want to regularize the track, but approx interpolates over the range of x's as opposed to treating the track as an ordered sequence. I've tried coercing it into a time series, but this only seems to work when the X's constantly increase. The following dummy track provides a glimpse of the problem with approx:
If you treat the x's and y's separately with approx you can get what you want (although I'm sure some careful thought would produce a better use of approx): x <- c(1,3,5,5,5,4,2,1.5) y <- c(1,1,1,2,3,3,3,3) xypair <- cbind(x,y) xypair rownames(xypair) <- 1:length(x) plot(x,y,type='l') points(xypair) text(x,y,rownames(xypair),offset=.5,pos=2) points(approx(xypair[,1],n=30)$y, approx(xypair[,2],n=30)$y,col=3,pch="*") BTW, I have a package for animal track data that contains a function called equalTime - it interpolates points in space (euclidean) based on an (approximation to an) equal time interval to create regular spaced points in time, assuming straight motion between fixes. You might find it useful. It's never really been finished, but I use it especially for the S4 validation of trajectory with "trip", and for quick speed filtering and time spent gridding. http://staff.acecrc.org.au/~mdsumner/Rutas/ HTH, Mike.