首页 > 解决方案 > 为 SECR 创建掩码时 as.vector(data) 出错

问题描述

我正在尝试使用 .shp 文件在 SECR 中创建掩码。总是收到此错误:as.vector(data) 中的错误:当我使用 make.mask 时,没有将这个 S4 类强制为向量的方法

这是我的代码:

fence <- rgdal :: readOGR('/Rdata/SECR', layer = 'building')

带驱动程序的 OGR 数据源:ESRI Shapefile 源:“/Rdata/SECR”,层:“building”,具有 2492 个特征 它有 1 个字段

library(secr)
#This is secr 3.2.1. For overview type ?secr

> qmask = make.mask(Quenda_traps,
+                   buffer = 300,
+                   type = "trapbuffer",
+                   poly = fence,
+                   poly.habitat = "FALSE")

as.vector(data) 中的错误:没有将此 S4 类强制为向量的方法

    dput(Quenda_traps)

structure(list(x = c(390576.21, 390637.85, 390594.93, 390528.49, 390646.58, 390488.12, 390681.01, 390499.98, 390632.29, 390677.26, 390642.7, 390710.33, 390690.37, 390741.81, 390588.01, 390655.06, 390575.97, 390246.66, 390340.13, 390236.33, 390309.59, 390295.93, 390164.11, 390065.71, 390120.42, 390117.17, 390091.7, 389875.57, 390179.69, 390157.45, 390164.94, 390151.02, 390172.17, 390246.28, 390263.25, 390256.32, 390308.2, 390135.06, 390093.3, 389914.13, 389916.76, 389869.37, 389809.17, 389782.5, 389818.78, 389802.75, 389818.78, 389771.52, 389792.74, 389791.25, 389905.36, 389832.62, 389886.16, 389863.21, 389908.68, 389912.46, 389902.05, 389528.11, 389661.6, 389689.54, 389657.88, 389678.71, 389569.25, 389618.44, 389564.87, 389615.37, 389662.18, 389630.96, 389713.09, 389654.91, 389744.37, 389762.02、389715.87、389696.2), y = c(6451727.44, 6451613.91, 6451566.89, 6451511.85, 6451416.66, 6451402.77, 6451287.32, 6451177.83, 6451164.84, 6451108.78, 6451188.57, 6450929.54, 6450855.04, 6450723.66, 6450716.47, 6450451.11, 6450343.83, 6451821.46, 6451645.08, 6451553.05, 6451588.21, 6451541.5 , 6451509.03, 6451442.56, 6451358.89, 6451222.49, 6451221.11, 6451303.03, 6451115.63, 6450989, 6450994.62, 6450797.13, 6450761.88, 6450717.22, 6450719.62, 6450399.14, 6450403.03, 6450352.38, 6450197.83, 6451841.15, 6451684.86, 6451526.92, 6451419.83, 6451441.72, 6451316.83, 6451367.43, 6451316.83 , 6451235.39, 6451105.9, 6450981.72, 6450992.93, 6450910.1, 6450935.07, 6450787.37, 6450685.86, 6450684.79, 6450600.42, 6451656.26, 6451534.65, 6451395.26, 6451267.42, 6451262.1, 6451257.59, 6451248.14, 6451138.91, 6451096.22, 6451132.2, 6450964.46, 6450964.24, 6450844.98, 6450864.8, 6450717.54, 6450620.58, 6450519.48)), class = c("traps", "data.frame"), row.names = c("1001", "1002", "1003", " 1004.1”、“1004.2”、“1005.1”、“1005.2”、“1006.1”、“1006.2”、“1006.3”、“1006.4”、“1007”、“1008”、“1009”、“1010”、“1011” 、“1012”、“2001”、“2002”、“2003.1”、“2003.2”、“2003.3”、“2004”、“2005”、“2006”、“2007.1”、“2007.2”、“2008.1”、“ 2008.2”、“2009.1”、“2009.2”、“2010.1”、“2010.2”、“2011.1”、“2011.2”、“2012.1”、“2012.2”、“2013”​​、“2014”、“3001”、“3002”、“3003”、“3004.1”、“3004.2”、“3005.1”、“3005.2”、“3005.3”、“3006”、“3007” ”、“3008.1”、“3008.2”、“3009.1”、“3009.2”、“3010”、“3011.1”、“3011.2”、“3012”、“4001”、“4002”、“4003”、“4004.1”、 “4004.2”、“4005.1”、“4005.2”、“4006”、“4007.1”、“4007.2”、“4008.1”、“4008.2”、“4009.1”、“4009.2”、“4010”、“4011”、“4012” "), 检测器 = "multi", 用法 = 结构(c(1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 , 1, 1,0, 0, 1, 1, 1, 1, 0, 1...), .Dim = c(74L, 85L), .Dimnames = list( c("1001", "1002", "1003", " 1004.1”、“1004.2”、“1005.1”、“1005.2”、“1006.1”、“1006.2”、“1006.3”、“1006.4”、“1007”、“1008”、“1009”、“1010”、“1011” 、“1012”、“2001”、“2002”、“2003.1”、“2003.2”、“2003.3”、“2004”、“2005”、“2006”、“2007.1”、“2007.2”、“2008.1”、“ 2008.2”、“2009.1”、“2009.2”、“2010.1”、“2010.2”、“2011.1”、“2011.2”、“2012.1”、“2012.2”、“2013”​​、“2014”、“3001”、“3002”、“3003”、“3004.1”、“3004.2”、“3005.1”、“3005.2”、“3005.3”、“3006”、“3007”、“3008.1”、“3008.2”、“ 3009.1”、“3009.2”、“3010”、“3011.1”、“3011.2”、“3012”、“4001”、“4002”、“4003”、“4004.1”、“4004.2”、“4005.1”、“4005.2” ,“4006”,“4007.1”,“4007.2”,“4008.1”,“4008.2”,“4009.1”,“4009.2”,“4010”,“4011”,“4012”),c(“1”,“2” "、"3"、"4"、"5"、"6"、"7"、"8"、"9"、"10”、“11”、“12”、“13”、“14”、“15”、“16”、“17”、“18”、“19”、“20”、“21”、“22” 、“23”、“24”、“25”、“26”、“27”、“28”、“29”、“30”、“31”、“32”、“33”、“34”、“ 35”、“36”、“37”、“38”、“39”、“40”、“41”、“42”、“43”、“44”、“45”、“46”、“47” 、“48”、“49”、“50”、“51”、“52”、“53”、“54”、“55”、“56”、“57”、“58”、“59”、“ 60", "61",“62”、“63”、“64”、“65”、“66”、“67”、“68”、“69”、“70”、“71”、“72”、“73”、“74” ”、“75”、“76”、“77”、“78”、“79”、“80”、“81”、“82”、“83”、“84”、“85”)))、spacex = 0.240000000048894,空间 = 0.21999999973923,间距 = 79.5867492192872)83"、"84"、"85"))),spacex = 0.240000000048894,spacey = 0.21999999973923,间距 = 79.5867492192872)83"、"84"、"85"))),spacex = 0.240000000048894,spacey = 0.21999999973923,间距 = 79.5867492192872)

标签: rrgdal

解决方案


推荐阅读