Page 1 of 2

Error when trying to use a mask

PostPosted: Thu Oct 06, 2016 3:34 pm
by jpdraper
I have just started my analysis on a 2-4 year data set (depending on region) and for the most part SECR has been working well with all of the errors so far being my own (hence my hesitance to bother y'all with this question).
My models have been running well prior to attempting to use a habitat mask. Now that I have tried to use a mask I am encountering an error that I do not know how to deal with. I tried tracing back the error's location using
Code: Select all
>
options(error=recover)
> options(show.error.location=TRUE)

to identify where the error was occurring, but I can't make heads nor tails of it since it is pretty deep into the backend code and the objects being called are ones that I am not sure how they relate to what I have entered.
Code: Select all
> options(error=recover)
> options(show.error.location=TRUE)
> library(secr)
> setwd("C:/Users/jpdraper/OneDrive - Auburn University 1/Master data/SECR data")
> MRBCH<-read.capthist('MRBcaptsub1415.txt', c('MRB2014.txt', 'MRB2015.txt'), detector = "proximity", fmt=c("trapID"))
No errors found :-)
> library(maptools)
> library(rgeos)
> setwd("C:/Users/jpdraper/OneDrive - Auburn University 1/Master data/mapping")
> MRBmaskin<-readShapePoly('MRB_mask_poly')
> MRBmask<-make.mask(traps(MRBCH), buffer=100, type="polybuffer", poly = MRBmaskin, poly.habitat = TRUE, spacing=500)
> g.D.S.<-secr.fit(MRBCH, model=g0~1, buffer=7500, trace=FALSE, ncores = 3, mask=MRBmask)
Error in (function (f, p, ..., hessian = FALSE, typsize = rep(1, length(p)),  :
  missing value in parameter

Above is the entirety of the code that I have entered and the resulting error. As sheepish as I will feel I am hoping that I just forgot an argument somewhere. Thank you for any help that can be provided

Re: Error when trying to use a mask

PostPosted: Thu Oct 06, 2016 5:02 pm
by murray.efford
Hi
Does the mask look right when you plot it and overlay the detectors?
Code: Select all
plot(MRBmask)
plot(traps(MRBCH), add = TRUE)

Murray

Re: Error when trying to use a mask

PostPosted: Fri Oct 07, 2016 9:23 am
by jpdraper
The mask looks good pretty much exactly as I expected it. Though I am not seeing the traps overlain on top.

Re: Error when trying to use a mask

PostPosted: Fri Oct 07, 2016 3:18 pm
by murray.efford
...which would explain why it's not working. I'm not sure why you need the unusual 'polybuffer' option. Maybe try without.
Murray

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 3:25 pm
by jpdraper
I honestly am still in the process of feeling out all of the different parameters to find which work best and the poly buffer sounded worth trying. Per your suggestion I switched to the trap buffer setting but have now a new error,
Code: Select all
> MRBmask<-make.mask(traps(MRBCH), buffer=100, poly = MRBmaskin, type = "trapbuffer", poly.habitat = TRUE, spacing=500)
> plot(MRBmask)
Error in if (yuin > xuin * ratio) yuin <- xuin * ratio else xuin <- yuin/ratio :
  missing value where TRUE/FALSE needed
> plot(traps(MRBCH), add = TRUE)
$`2014`
NULL

$`2015`
NULL
the traps are now displaying but obviously over a generic mask since the created one is not plotting

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 3:29 pm
by murray.efford
It looks like there is some problem with your polygon or trap coordinates. If you like to send me the files offline then I may be able to diagnose it.
Murray

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 3:33 pm
by jpdraper
That would be amazingly helpful what would be the best contact method to transfer those files?

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 3:37 pm
by murray.efford
I assumed you would just attach them to an email (you should be able to find my email address). If the files are too big for that then there's always Dropbox.

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 3:58 pm
by murray.efford
The data confirm that your traps and mask polygons do not overlap, presumably because you used different coordinate systems (projections):

> t(bbox(MRBmaskin))
x y
min 711863.6 840162.1
max 827114.0 1002809.2

> apply(traps(MRBCH)[[1]],2,range)
x y
[1,] 363679 3365378
[2,] 461974 3495156

Re: Error when trying to use a mask

PostPosted: Mon Oct 10, 2016 4:44 pm
by jpdraper
Thank you. I feel a little sheepish that it came down to the fact that I hadn't reprojected my maps into the correct UTM projection before saving them for importing as a buffer. However I am glad it was a quick fix. Thank you so much for your timely and concise help. The model seems to be running smoothly now.