116 views
Skip to first unread message

Shannon Braun

unread,
Dec 13, 2018, 5:33:00 AM12/13/18
to secr...@googlegroups.com

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' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: 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

 


--
Shannon Braun

PhD candidate
Department of Ecology, Environment and Evolution | La Trobe University | Bundoora, 3086 Australia
captfile_both.csv
trapfile_both.csv

Murray Efford

unread,
Dec 13, 2018, 3:07:54 PM12/13/18
to shannon...@gmail.com, secr
Hi Shannon

I think this is going to be easy to fix, but I'm not quite there yet.

The way you construct bothCH results in a 2-session capthist with both inside and outside cameras operated in each session - not what you intended. I suggest importing all data to a single-session capthist (i.e. start with all session codes = 1) and then using split.capthist. I'll show you how.

But first, is it OK for you also to attach mask_in.shp (all parts)? I don't see why you would need two shapefiles if mask_out.shp is just the complement of mask_in.shp, given you can set poly.habitat to TRUE or FALSE (and why both FALSE in your code?)

Murray

--
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.

Murray Efford

unread,
Dec 14, 2018, 4:02:11 AM12/14/18
to secr
I editted your captfile so all session = 1 (see attached), then implemented my earlier suggestion. It seems no cameras were working on last 2 days outside the fence, so I shortened that. Seems to work with secr.fit(bothCH, mask = masks,...)


###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')
captfile_both.xlsx
Reply all
Reply to author
Forward
0 new messages