Error when trying to use a mask

announcements (new versions, changes, bugs, installation problems...) related to program DENSITY and the R package secr

Error when trying to use a mask

Postby jpdraper » Thu Oct 06, 2016 3:34 pm

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
jpdraper
 
Posts: 5
Joined: Thu Oct 06, 2016 3:12 pm

Re: Error when trying to use a mask

Postby murray.efford » Thu Oct 06, 2016 5:02 pm

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
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Error when trying to use a mask

Postby jpdraper » Fri Oct 07, 2016 9:23 am

The mask looks good pretty much exactly as I expected it. Though I am not seeing the traps overlain on top.
jpdraper
 
Posts: 5
Joined: Thu Oct 06, 2016 3:12 pm

Re: Error when trying to use a mask

Postby murray.efford » Fri Oct 07, 2016 3:18 pm

...which would explain why it's not working. I'm not sure why you need the unusual 'polybuffer' option. Maybe try without.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Error when trying to use a mask

Postby jpdraper » Mon Oct 10, 2016 3:25 pm

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
jpdraper
 
Posts: 5
Joined: Thu Oct 06, 2016 3:12 pm

Re: Error when trying to use a mask

Postby murray.efford » Mon Oct 10, 2016 3:29 pm

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
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Error when trying to use a mask

Postby jpdraper » Mon Oct 10, 2016 3:33 pm

That would be amazingly helpful what would be the best contact method to transfer those files?
jpdraper
 
Posts: 5
Joined: Thu Oct 06, 2016 3:12 pm

Re: Error when trying to use a mask

Postby murray.efford » Mon Oct 10, 2016 3:37 pm

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.
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Error when trying to use a mask

Postby murray.efford » Mon Oct 10, 2016 3:58 pm

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
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Error when trying to use a mask

Postby jpdraper » Mon Oct 10, 2016 4:44 pm

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.
jpdraper
 
Posts: 5
Joined: Thu Oct 06, 2016 3:12 pm

Next

Return to software problems/news

Who is online

Users browsing this forum: No registered users and 2 guests