Trackage / trip

trip package development
http://trackage.github.io/trip/
12 stars 2 forks source link

speedfilter uses wrong units for projected data #6

Closed mdsumner closed 5 years ago

mdsumner commented 8 years ago

speedfilter needs a max.speed in metres per hour if it's projected, but in km per hour if it's in longlat.

The code behind

R summary(trip)

then reports mean/max speeds in metres per hour if it's projected, or km per hour if it's in longlat.

library(trip)

library(adehabitatLT)
data(porpoise)
ptrip <- as.trip(porpoise)
ptrip <- ptrip[, c("id", "date")]
## determined by trial and error
proj4string(ptrip) <- CRS("+proj=utm +zone=21 +ellps=WGS84 +units=m +no_defs")

library(rgdal)
ltrip <- spTransform(ptrip, "+proj=longlat +ellps=WGS84")

summary(ptrip)
summary(ltrip)

filter_ptrip <- ptrip[speedfilter(ptrip, max.speed= 50000), ]
filter_ltrip <- ltrip[speedfilter(ltrip, max.speed = 5), ]

Reported by Anthony Fischbasch

mdsumner commented 5 years ago

I actually think this is ok, it's probably a bad choice long ago to use km/h for longlat, but that's what happened.