make.mask to exclude non-habitat

Hello Murray,
I've been troubleshooting the make.mask function but not having any luck through forums or with the secr guide. Hopefully you can help me figure out what I've done wrong here.
I have created a polygon shapefile in ArcMap that includes all of the potentially useable habitat at my study site, which excludes non-habitat. I'm unclear in what exact format the program needs this shape file to be in, because no matter how I input it I keep getting errors back.
Here's what I've done:
#Basic mask: no errors
#Approach 1: Input as shapefile
#Approach 2: Input as .csv
If you could help me sort out what has gone wrong I'd really appreciate it!
Best wishes,
Angela
I've been troubleshooting the make.mask function but not having any luck through forums or with the secr guide. Hopefully you can help me figure out what I've done wrong here.
I have created a polygon shapefile in ArcMap that includes all of the potentially useable habitat at my study site, which excludes non-habitat. I'm unclear in what exact format the program needs this shape file to be in, because no matter how I input it I keep getting errors back.
Here's what I've done:
- Code: Select all
library(secr)
library(sp)
library(rgdal)
captfile <- read.delim("CaptAld19.txt")
trapfile <- read.delim("trapsAld19.txt")
Ald2019CH <- read.capthist("CaptAld19.txt", "trapsAld19.txt", detector="count")
Ald2019aCH <- read.capthist("CaptAld19.txt", "trapsAld19.txt",
fmt=NULL, detector="count"),
noccasions=40,
markocc=c(1,1,0,1,1,0,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0))
Ald2019aCH <- addSightings(Ald2019aCH, nonID="TmAld19.txt",
unmarked="TuAld19.txt", uncertain="TnAld19.txt")
#Basic mask: no errors
- Code: Select all
mask <- make.mask(traps(Ald2019aCH))
#Approach 1: Input as shapefile
- Code: Select all
library(sf)
st_read("Useable.shp")
Useable <- st_read("Useable.shp")
make.mask(traps(Ald2019aCH), type='trapbuffer', buffer=400, poly='Useable')
#Error in insidecpp(xy1, 0, np - 1, as.matrix(poly)) :
#Not compatible with requested type: [type=character; target=double].
#Troubleshooting, input differently
UsedHabitat <- rgdal::readOGR(dsn=".", layer="Export_usepts")
UsedHabitat2 <- rgdal::readOGR(dsn=".", layer="Useable")
class(UsedHabitat) #This one is "SpatialPointsDataFrame"
class(UsedHabitat2) #This one is "SpatialPolygonsDataFrame"
make.mask(traps, spacing=10, type="trapbuffer", poly="UsedHabitat2", poly.habitat=TRUE)
#Error in nearestcpp(as.matrix(X), as.matrix(trps)) :
#Not compatible with requested type: [type=character; target=double].
make.mask(traps, spacing=10, type="polybuffer", poly="UsedHabitat2", poly.habitat=TRUE)
#Error in xl + buffx : non-numeric argument to binary operator
#Approach 2: Input as .csv
- Code: Select all
Useablept <- read.csv('Useable_Pts.csv', header=TRUE, sep=",", dec=".")
make.mask(traps(Ald2019aCH), type='trapbuffer', poly='Useablept')
#Error in insidecpp(xy1, 0, np - 1, as.matrix(poly)) :
#Not compatible with requested type: [type=character; target=double]
#Troubleshoot
make.mask(traps, type=c("trapbuffer"), buffer=400, poly=c("Useable"))
#error "Object of type 'closure' is not subsettable.
#Troubleshoot
make.mask(traps(Ald2019aCH), type=c("trapbuffer"), buffer=400, poly=c("Useable"))
# error "In inside cpp(cy1, 0, np - 1, as.matrix(poly)):
#Not compatible with requested type: [type=character; target=double].
If you could help me sort out what has gone wrong I'd really appreciate it!
Best wishes,
Angela