[R-sig-eco] For a given location, identify minimum kernel density isopleth

NZHelen helen.nathan at auckland.ac.nz
Fri Apr 10 01:18:40 CEST 2015


I am undertaking research looking at the interactions of individual rats with
a grid of traps distributed across the landscape (I have x, y coordinates
for all trap locations). For each rat, I have generated a kernel utilisation
density "home range" estimate using the R package adehabitatHR. What I'd
like to do next is the following:

1- For each rat, calculate fine-scale home range contours from 1 - 99%

2- For each trap, calculate the minimum isopleth on which it is located: for
example, trap 1 might "first" be on the 20% isopleth, trap 2 might "first"
be on the 71% isopleth

My ultimate goal is to use the minimum isopleths calculated in a logistic
regression to estimate the probability that a particular rat will
"encounter" a particular trap within a specified time period.

Step 1 is easy enough but I'm having trouble imagining a way to accomplish
step 2 short of plotting it all out manually (possible but I think there
must be a better way). I suspect that part of my problem is that I'm new to
both R and analysis of spatial data and I'm probably not searching with the
right key words. Of what I've managed to find, the discussion that most
closely resembles what I want to do is this.

How can I get the value of a kernel density estimate at specific points?
<http://stackoverflow.com/questions/16201906/how-can-i-get-the-value-of-a-kernel-density-estimate-at-specific-points>  

The above succeeds in calculating the probability value at specific points
within a kernel utilisation distribution. However, what I'm trying to do is
more to assign specific locations to a "category" - i.e. 5% category, 22%
category etc.

Here is a small sample of my rat location data (coordinate system 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

And here are the location data for my grid of traps:

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

Below is the code I used to calculate 1-99% home range contours using
package adehabitatHR (Step 1). In addition, the code to plot selected home
range isopleths over the grid of traps.

Can anyone help me get started on Step 2? I'd be grateful for any ideas.

Thanks.


### 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)





--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/For-a-given-location-identify-minimum-kernel-density-isopleth-tp7579383.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.



More information about the R-sig-ecology mailing list