if (FALSE) {
fxi(secrdemo.0, i = 1, X = c(365,605))
## contour first 5 detection histories
plot(secrdemo.0$capthist)
fxiContour (secrdemo.0, i = 1:5, add = TRUE,
plotmode = TRUE, drawlabels = FALSE)
## extract modes only
## these are more reliable than those from fit.mode called directly as
## they use a contour-based approximation for the starting point
fxiout <- fxiContour (secrdemo.0, i = 1:5, plt = FALSE, fitmode = TRUE)
t(sapply(fxiout, "[[", "mode"))
## using fill colours
## lty = 0 suppresses contour lines
## nx = 256 ensures smooth outline
plot(traps(captdata))
fxiContour(secrdemo.0, i = 1:5, add = TRUE, p = c(0.5,0.95), drawlabels
= FALSE, nx = 256, fill = topo.colors(4), lty = 0)
## output as simple features
sf <- fxiContour(secrdemo.0, i = 1:3, plt = FALSE, p = c(0.5,0.95),
nx = 256, output = 'sf', fitmode = TRUE)
## save as ESRI shapefile testsf.shp etc.
library(sf)
st_write(sf, 'testsf.shp')
## plot contours and modes
plot(st_as_sfc(sf)) # outline only
points(sf$modex, sf$modey)
## output as SpatialPolygonsDataFrame
spdf <- fxiContour(secrdemo.0, i = 1:3, plt = FALSE, p = c(0.5,0.95),
nx = 256, output = 'SPDF', fitmode = TRUE)
sp::plot(spdf)
points(data.frame(spdf))
}
Run the code above in your browser using DataLab