对于给定位置,确定最小核密度等值线

时间:2015-03-31 01:54:00

标签: r spatial kernel-density

我正在进行研究,研究个体大鼠与横跨景观分布的陷阱网格的相互作用(我有所有陷阱位置的x,y坐标)。对于每只大鼠,我使用R包adehabitatHR生成了核利用密度“家庭范围”估计。接下来我要做的是:

1-对于每只大鼠,计算1 - 99%的精细家庭范围轮廓

2-对于每个陷阱,计算它所在的最小等值线:例如,陷阱1可能“首先”在20%的等值线上,陷阱2可能“首先”在71%的等值线上

我的最终目标是使用逻辑回归中计算的最小等值线来估计特定大鼠在特定时间段内“遇到”特定陷阱的概率。

第1步很容易,但我无法想象一种方法来完成第2步,而不是手动绘制全部(可能但我认为必须有更好的方法)。我怀疑我的问题的一部分是我对R和空间数据的分析都是新手,我可能不会用正确的关键词进行搜索。在我设法找到的内容中,与我想要做的最相似的讨论就是这个。

How can I get the value of a kernel density estimate at specific points?

以上成功地计算了内核利用率分布内特定点的概率值。但是,我要做的更多是将特定位置分配到“类别” - 即5%类别,22%类别等。

以下是我的大鼠位置数据的小样本(坐标系NZTM)

RatID   Easting Northing
18  1732782.018 5926656.26
18  1732746.074 5926624.161
18  1732775.206 5926617.687
18  1732750.443 5926653.985
18  1732759.188 5926645.705
18  1732765.358 5926624.287
18  1732762.588 5926667.765
18  1732707.336 5926638.793
18  1732759.54  5926693.451
18  1732743.532 5926645.08
18  1732724.905 5926637.952
18  1732729.757 5926594.709
18  1732743.725 5926603.689
18  1732754.217 5926591.804
18  1732733.287 5926619.997
18  1732813.398 5926632.372
18  1732764.513 5926609.795
18  1732756.472 5926607.948
18  1732771.352 5926609.855
18  1732789.088 5926598.158
18  1732768.952 5926620.593
18  1732742.667 5926630.391
18  1732751.399 5926595.63
18  1732749.846 5926624.015
18  1732756.466 5926661.141
18  1732748.507 5926597.018
18  1732782.934 5926620.3
18  1732779.814 5926633.227
18  1732773.356 5926613.596
18  1732755.782 5926627.243
18  1732786.594 5926619.327
18  1732758.493 5926610.918
18  1732760.756 5926617.973
18  1732748.722 5926621.693
18  1732767.133 5926655.643
18  1732774.129 5926646.358
18  1732766.18  5926659.081
18  1732747.999 5926630.82
18  1732755.94  5926606.326
18  1732757.592 5926586.467

以下是我的陷阱网格的位置数据:

TrapNum Easting Northing
HA1 1732789.055 5926589.589
HA2 1732814.738 5926605.615
HA3 1732826.837 5926614.635
HA4 1732853.275 5926621.766
HA5 1732877.903 5926638.804
HA6 1732893.335 5926649.771
HA7 1732917.186 5926651.287
HA8 1732944.25  5926669.952
HA9 1732963.233 5926679.758
HB1 1732778.721 5926613.718
HB2 1732798.169 5926624.735
HB3 1732818.44  5926631.303
HB4 1732844.132 5926647.878
HB5 1732862.387 5926662.465
HB6 1732884.118 5926671.112
HB7 1732903.641 5926681.234
HB8 1732931.883 5926695.332
HB9 1732947.286 5926698.757
HC1 1732766.385 5926629.555
HC2 1732785.31  5926647.128
HC3 1732801.985 5926657.742
HC4 1732835.289 5926664.553
HC5 1732843.434 5926694.72
HC6 1732862.648 5926702.187
HC7 1732878.385 5926709.82
HC8 1732916.886 5926712.215
HC9 1732935.947 5926715.582
HD1 1732755.253 5926654.033
HD2 1732774.911 5926672.812
HD3 1732794.617 5926671.724
HD4 1732820.064 5926689.754
HD5 1732816.794 5926714.769
HD6 1732841.166 5926732.481
HD7 1732865.646 5926734.21
HD8 1732906.592 5926738.893
HD9 1732930.1   5926752.73

以下是我用于使用包adehabitatHR计算1-99%家庭范围轮廓的代码(步骤1)。此外,用于绘制所选择的家庭范围的代码是陷阱网格上的等值线。

### First, load adehabitatHR and dependents

## specifying which variables are coordinates converts the dataframe into class SpatialPointsDataFrame

coordinates (RatLocs) = c("Easting", "Northing")

# create and store in object kudH KUDs using default bivariate normal kernel function and least-squares-cross-validation as smoothing bandwidth

kudH = kernelUD(RatLocs[,1], h = "LSCV") 
kudH

## estimating home range from the KUD - mode VECTOR
homerange = getverticeshr(kudH)

## calculate home-range area for ALL probability levels (every 1%)
hr1to100 = kernel.area(kudH, percent = seq(1,100, by =1))

# generates error - for 100% kernel. rerun kernel UD with larger extent parameter.
## tried a range of values for other extents. Couldn't get one that worked for a 100% isopleth, 99% works
hr1to99 = kernel.area(kudH, percent = seq(1,99, by =1))

## An example of calculating and plotting selected home range isopleths over the grid of traps

## plot the trap grid
plot(Grid[,2], Grid[,3], xlab="Easting", ylab="Northing", pch=3, cex = 0.6, col="black", bty = "n", xlim=c(1742650,1743100), ylim=c(5912900,5913200), main = "KUD Home Range rat 33")
text(Grid[,2], Grid[,3], Grid[,1], cex=0.6, pos=2)

# Calculate and plot 95%, 75% and 50% contours for rat ID 33 (rat 2 in dataset)

HR95pc = getverticeshr(kudH)
plot(HR95pc[2,], col= rgb (1,0,0, alpha =0.1), border = "red1", add=TRUE)
HR75pc = getverticeshr(kudH, percent=75)
plot (HR75pc[2,], col = rgb(0,0,1, alpha =0.3), border = "purple", add=TRUE)
HR50pc = getverticeshr(kudH, percent=50)
plot(HR50pc[2,], col = rgb (0,1,1, alpha=0.3), border = "blue2", add=TRUE)

# Add individual location points for rat ID 33

rat33L = subset(RatLocs, RatID =="33")
plot(rat33L[,1], pch = 16, col = "blue", add=TRUE)

任何人都可以帮助我开始第2步吗?我很感激任何想法。

感谢。

0 个答案:

没有答案