Hi Chris,
I'm trying to work with the akde
contours to be able to filter locations and extract only those that
fall within the 95% home range. I have calculated the akde's, and wrote
them as a shapefile using for example:
writeShapefile(AKDE$G01_Winter_2019, folder,
file=NULL,level.UD=0.95,level= FALSE) I set level to false because I
don't want the confidence intervals.
When I preview this
shapefile in QGIS, it looks exactly what it should look like, and I
don't have the confidence intervals. If I read that shapefile back into r
as an 'sf' to mask locations I don't want, it has the confidence
intervals again for some reason, and it also appears to be distorted. If
I read it as a spatial polygon data frame it also has the confidence
intervals back, and I can't seem to be able to plot the locations on top
of it.
Any ideas as to how to best do this and why I may be encountering these problems would be really useful!
I tried attaching my code, the shapefile and the locations I'm using- in case they helped- but I wouldn't let me post this (I can share by regular email if it's useful)
Thank you,
Malena.
datos <- read.csv("G01_ctmm.csv",header=T)
head(datos)
str(datos)
#---------------#
# create AKDE---#
#---------------#
datos$id<-datos$Burst
burst<-as.telemetry(dat, projection = CRS("+proj=utm +zone=19 +south +datum=WGS84"))
#plot all guanacos, and ind guanacos
plot(burst)
COL <- rainbow(length(burst))
plot(burst,col=COL)
# look back at G01
COLG01 <- color(burst$G01_Winter_2019,by="time")
plot(burst$G01_Winter_2019,col=COLG01)
SVF <- list()
for(i in 1:length(burst)){
print(i)
SVF[[i]] <- variogram(burst[[i]])
}
names(SVF) <- names(burst)
zoom(SVF$G01_Winter_2019)
## fit models to all animals
FIT <- list()
for(i in 1:length(burst)){
print(i)
GUESS <- ctmm.guess(burst[[i]],interactive=FALSE)
FIT[[i]] <- ctmm.select(burst[[i]],GUESS,verbose=TRUE,trace=2)
}
names(FIT) <- names(burst)
AKDE <- list()
KDE <- list()
for(i in 1:length(burst)){
print(i)
AKDE[[i]] <- akde(burst[[i]],FIT[[i]][[1]])
IID <- ctmm.fit(burst[[i]],ctmm(isotropic=TRUE))
KDE[[i]] <- akde(burst[[i]],IID)
}
names(AKDE) <- names(burst)
names(KDE)<-names(burst)
# AKDE versus KDE area
summary(KDE$G01_Winter_2019)
summary(AKDE$G01_Winter_2019)
plot(AKDE$G01_Winter_2019)
# comparison plot
EXT <- extent(list(burst,AKDE$G01_Winter_2019))
par(mfrow=1:2)
plot(burst$G01_Winter_2019,AKDE$G01_Winter_2019,ext=EXT)
title("AKDE")
plot(burst$G01_Winter_2019, KDE$G01_Winter_2019,ext=EXT)
title("KDE")
par(mfrow=c(1,1))
folder <- paste(getwd(),"/shp-output2", sep="")
plot(AKDE$G01_Winter_2019)
str(AKDE$G01_Winter_2019)
writeShapefile(AKDE$G01_Winter_2019, folder, file=NULL,level.UD=0.95,level= FALSE)
cont<-st_read("G01_Winter_2019.shp")
cont<-cont[2,]# I don't know how else to loose the CI
plot(cont)
winter<-subset(datos, datos$id== "G01_Winter_2019")
coordinates(winter) <- c("long","lat")
proj4string(winter) <- "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
plot(winter, add=TRUE) # when adding my locations I see the HR polygon appears to be distorted
pol<-shapefile("G01_Winter_2019.shp")
plot(pol)
plot(winter, add=TRUE) #nothing happens