Message-ID: <0e255278ad5b6647f1ef64b539794b30@uevora.pt>
Date: 2015-02-06T17:45:11Z
From: carmoms
Subject: Adehabitat NMs Error
Hello,
I?m trying to calculate Null Models for Animal Movement Analysis using
adehabitatLT, but each time I try to constrain the random movements an
error occurs.
So the codes I use are:
# Transform my locations points in ltraj
daho025<-as.character(Loc_025$DataHora)
head(daho025)
[1] "19-04-201200:56" "19-04-201201:35" "19-04-201205:48"
"19-04-201206:30" "19-04-201220:09" "19-04-201220:48"
daho1025 <-
as.POSIXct(strptime(as.character(Loc_025$DataHora),"%d-%m-%Y%H:%M"))
head(daho1025)
[1] "2012-04-19 00:56:00 BST" "2012-04-19 01:35:00 BST" "2012-04-19
05:48:00 BST" "2012-04-19 06:30:00 BST" "2012-04-19 20:09:00 BST"
"2012-04-19 20:48:00 BST"
Apo025 <- as.ltraj(xy = Loc_025[,c("X_WGS84","Y_WGS84")],
date = daho1025, id = Loc_025$Codigo_ind)
# Transform my raster in to SpatialPixelsDataFrame:
PatTalSPDF<-as(PatTal, "SpatialPixelsDataFrame")
# To calculate the random walks:
# my function
myfunc <- function(x, par)
{par(mar = c(0,0,0,0))
image(par)
lines(x[,1], x[,2], lwd=2)}
# constrain function
consfun <- function(x, par)
{coordinates(x) <- x[,1:2]
ov <- over(x, geometry(PatTalSPDF))
return(all(!is.na(ov)))}
rxy <- apply(coordinates(S),2,range)
rxy
nmo2 <- NMs.randomShiftRotation(na.omit(Apo025), rshift = TRUE, rrot =
TRUE,rx = rxy[,1], ry = rxy[,2], treatment.func = myfunc, treatment.par
= PatTalSPDF, constraint.func=consfun, constraint.par=PatTalSPDF,
nrep=9)
The result is always:
Error : identicalCRS(x, y) is not TRUE
Error in FUN(1L[[1L]], ...) :
The constraint function fails for animal 1 :
it should work at least for all observed trajectories
I used the same function with the example in the package reference
manual and it worked. Can anyone help me?
Thank you for your time.
Best wishes,
Carmo Silva