Hi Murray and group,
I have spent considerable time trying to troubleshoot some secr problems myself having read Murrays vignettes, the notes from his workshop I attended (great workshop Murray) and many forums. I really would appreciate some guidance please.
I am comparing the density and ranging behaviour of goannas inside and outside of a predator excluded fence. Each side of the fence has 36 camera detectors that are approximately 180m apart and form a six by six detector grid. The detector grids are actually quite close to the fence, some detectors as close as 50 metres.
I have taken a multi session approach with the detector grids on each side of the fence being considered as two separate sessions. Because the detector array for both sessions are so close together the buffer zones overlap and this needs to be taken into consideration when building my habitat mask. I need a mask for inside the fence that excludes the polygon outside of the fence and a mask for the session outside the fence that excludes the polygon inside the fence.
My understanding is that I must create a list of traps objects that is then put into the traps argument for each of my two masks. Then I need to combine those two masks as a list that becomes the mask that is read into the secr.fit function. So far I am ok excluding the non-habitat area for creating a mask for both sessions and I can combine them into a list. I am not sure how to handle my traps files. I have tried to make separate trap files by deleting the non-required detectors rows from the csv file and when I try to use read.traps with the edited file I get this error message.
Error in read.table(file, row.names = 1, as.is = T, colClasses = colcl, :
duplicate 'row.names' are not allowed
I don’t understand how to fix this. Read.traps works perfectly fine prior to editing out the non required rows of the file that are for the other sessions detectors. I am pretty sure I cannot use the file that includes traps from both sessions and that I need to create a list of traps (one traps object for each session).
The relevant code so far is below.
###Input files and create capthist####
captfile <- "captfile_both.csv"
trapfile <- "trapfile_both.csv"
trapfile_both<- read.csv("trapfile_both.csv")
buffer <- 800
bothCH <- read.capthist(captfile = captfile,
trapfile = trapfile,
sep = ",", skip = 1,
detector = "proximity",
covnames = c("age")
)
#### Clear repeat observations and subset sessions#####
bothCH <- reduce(bothCH, dropunused = FALSE) # clear out repeat observations
verify(bothCH)
inside_CH <- subset(bothCH, session = c(1))
outside_CH <- subset(bothCH, session = c(2))
###Create traps object, read polygons using rgdal and create masks###
trapfile_both <- read.traps(trapfile,
sep = ",",
skip = 1,
detector = "proximity")
******read.traps works fine when using the original trap file with both sessions traps. When I delete one of the sessions I get the above mentioned error about row names. I am pretty sure I need two traps files read in as objects that I then use to create a list and that list is read into the traps argument of make.mask*********
Insidepoly<-rgdal::readOGR("mask_in.shp", stringsAsFactors = FALSE)
Outsidepoly<-rgdal::readOGR("mask_out.shp", stringsAsFactors = FALSE)
maskinside <- make.mask(trapfile_both,
spacing = 50,
buffer = buffer,
type = 'trapbuffer',
poly = Outsidepoly,
poly.habitat = FALSE,
keep.poly = TRUE,
check.poly = TRUE)
maskoutside <- make.mask(trapfile_both,
spacing = 50,
buffer = buffer,
type = 'trapbuffer',
poly = Insidepoly,
poly.habitat = FALSE,
keep.poly = TRUE,
check.poly = TRUE)
mask<-list(maskinside, maskoutside)
I’m also having trouble trying to plot this and I suspect it may in part be due to me trying to use a single traps object that is not listed by session with a list of masks. Otherwise something may be wrong with the below code which I attempted to adapt from your multi session vignette. I can only get one mask to plot and it does not include the trapfiles. When I adjust the order of the two masks in my list then it seems to effect which mask gets plotted so I suspect it is only plotting the first mask in the list. I also get an error message.
par(mfrow = c(1,2), mar = c(5,4,4,2))
for(sess in 1:length(trapfile_both)) {
plot(mask[[sess]])
plot(traps(trapfile_both)[[sess]], add = TRUE) }
Error in plot.window(...) : need finite 'xlim' valuesIn addition: Warning messages:1: In min(x) : no non-missing arguments to min; returning Inf2: In max(x) : no non-missing arguments to max; returning -Inf3: In min(x) : no non-missing arguments to min; returning Inf4: In max(x) : no non-missing arguments to max; returning -Inf5: In plot.window(...) : "add" is not a graphical parameter
All of my models have run fine without the multi session mask but I suspect my estimates will change once I exclude non-habitat.
I have attached my traps and capthist files for reference. Any advice is greatly appreciated. I am flailing at the moment.
Cheers
--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
###Input files and create capthist####
captfile <- "captfile_both.xlsx"
trapfile <- "trapfile_both.csv"
buffer <- 800
bothCH <- read.capthist(captfile = captfile, trapfile = trapfile,
skip = 1, detector = "proximity",
covnames = c("age"))
bothCH <- split(bothCH, grepl('IN',rownames(traps(bothCH))), bytrap = TRUE)
# drop last 2 occasions for OUT (no cameras working)
bothCH[[1]] <- subset(bothCH[[1]], occasions=1:78)
usage(traps(bothCH[[1]])) <- usage(traps(bothCH[[1]]))[,1:78]
#### Clear repeat observations
bothCH <- reduce(bothCH, dropunused = FALSE)
verify(bothCH)
session(bothCH) <- c('OUT',"IN")
par(mfrow = c(1,2))
plot(bothCH)
Insidepoly <- rgdal::readOGR("mask_in.shp", stringsAsFactors = FALSE)
maskoutside <- make.mask(traps(bothCH[[1]]), buffer = buffer, type = 'trapbuffer',
poly = Insidepoly, poly.habitat = FALSE)
maskinside <- make.mask(traps(bothCH[[2]]), buffer = buffer, type = 'trapbuffer',
poly = Insidepoly, poly.habitat = TRUE)
masks <- list(maskoutside, maskinside)
par(mfrow=c(1,2))
plot(maskoutside)
plot(traps(bothCH[[1]]), add = TRUE)
mtext (side=3, 'OUT')
plot(maskinside)
plot(traps(bothCH[[2]]), add = TRUE)
mtext (side=3, 'IN')