The TuktuTools
packages offers a range of functions
allowing to easily summarize data and estimate movement rate and range
distributions. Some examples are below. They are based off the “prepped”
caribou data from Part I, which clips the movement to a short period for
the analysis of parturitions.
require(TuktuTools)
data(caribou)
caribou_sf <- st_as_sf(caribou,
coords = c("Lon","Lat"), crs = 4326)
caribou_prepped <- prepData(caribou, start = "05-19", end = "07-07") %>%
st_as_sf(coords = c("Lon","Lat"), crs = 4326)
## Period clipped to 05-19 - 07-07
## Number of excluded individuals-years: 2
getDailyMean()
takes any large movement dataset and
returns the daily mean locations for each individual for each day for
each year of observations.
Let’s calculate the daily mean locations for individuals during the calving period.
caribou_daily_mean <- getDailyMean(caribou_prepped)
caribou_daily_mean
## Simple feature collection with 535 features and 7 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -37398.69 ymin: 7070335 xmax: 454152 ymax: 7344976
## Geodetic CRS: WGS 84
## First 10 features:
## ID Year yday X Y sex Time
## 1 Dancer 2002 139 -130.5903 64.93708 f 2002-05-19 08:00:00
## 2 Dancer 2002 140 -130.4412 65.17436 f 2002-05-20 08:00:00
## 3 Dancer 2002 141 -130.2851 65.35544 f 2002-05-21 08:00:00
## 4 Dancer 2002 142 -130.0343 65.54760 f 2002-05-22 08:00:00
## 5 Dancer 2002 143 -129.6419 65.74962 f 2002-05-23 08:00:00
## 6 Dancer 2002 144 -129.4325 65.92092 f 2002-05-24 08:00:00
## 7 Dancer 2002 145 -129.1612 66.02657 f 2002-05-25 08:00:00
## 8 Dancer 2002 146 -129.0105 66.01968 f 2002-05-26 08:00:00
## 9 Dancer 2002 147 -129.2951 66.01536 f 2002-05-27 08:00:00
## 10 Dancer 2002 148 -129.5554 66.02423 f 2002-05-28 08:00:00
## geometry
## 1 POINT (141896 7222972)
## 2 POINT (152022 7248435)
## 3 POINT (161623.4 7267659)
## 4 POINT (175623.2 7287645)
## 5 POINT (196039.9 7308092)
## 6 POINT (207557.8 7326106)
## 7 POINT (221013.1 7336598)
## 8 POINT (227746.6 7335168)
## 9 POINT (214846.9 7335958)
## 10 POINT (203188.8 7338148)
This function becomes handy when we are dealing with very large dataset, to homogenize data, by having one location per day for each individual, and do further analyses not requiring a fine fix rate.
The package contains a function which is calculating the movement
rate between successive locations for each individual:
getSpeed
.
Calculating the movement rate between successive daily locations. Note that this function calculate movement rate for each individual separately, but if individuals are monitored several years with a break in between (as in this case, since we considered only the calving period), it is essential to apply this function to each individual and year separately!
daily_mr <- caribou_daily_mean %>% mutate(ID_year = paste(ID, Year)) %>%
getSpeed(id.col = "ID_year")
head(daily_mr)
## Simple feature collection with 6 features and 15 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 241878.2 ymin: 7316549 xmax: 250584.8 ymax: 7328800
## Geodetic CRS: WGS 84
## ID Year yday X Y sex Time ID_year
## 1 Comet 2006 139 -128.4736 65.87219 f 2006-05-19 08:00:40 Comet 2006
## 2 Comet 2006 140 -128.6367 65.95427 f 2006-05-20 08:00:00 Comet 2006
## 3 Comet 2006 141 -128.6444 65.97626 f 2006-05-21 08:00:00 Comet 2006
## 4 Comet 2006 142 -128.6755 65.91915 f 2006-05-22 08:00:00 Comet 2006
## 5 Comet 2006 143 -128.5542 65.92500 f 2006-05-23 08:00:20 Comet 2006
## 6 Comet 2006 144 -128.5148 65.92819 f 2006-05-24 08:00:00 Comet 2006
## x y z dt sl dhours speed
## 1 250584.8 7316549 250585+7316549i NA NA 0.00000 NA
## 2 243987.1 7326326 243987+7326326i 23.98889 11794.837 23.98889 491.67919
## 3 243859.4 7328800 243859+7328800i 24.00000 2477.436 47.98889 103.22652
## 4 241878.2 7322583 241878+7322583i 24.00000 6525.256 71.98889 271.88566
## 5 247440.4 7322739 247440+7322739i 24.00556 5564.371 95.99444 231.79513
## 6 249257.8 7322935 249258+7322935i 23.99444 1828.024 119.98889 76.18532
## geometry
## 1 POINT (250584.8 7316549)
## 2 POINT (243987.1 7326326)
## 3 POINT (243859.4 7328800)
## 4 POINT (241878.2 7322583)
## 5 POINT (247440.4 7322739)
## 6 POINT (249257.8 7322935)
We can visualize the movement rate of each individual through time.
To have all the individuals on the same figure, we add a column
doy
(i.e, day of year). We also need to create a column for
each ID-Year, as some individuals have been monitored several years.
daily_mr <- daily_mr %>% mutate(doy = yday(Time), ID_Year = as.factor(paste(ID, Year, sep = "_")))
ggplot(data = daily_mr, aes(x = doy, y = speed, group = ID_Year, colour = ID_Year)) + geom_line()
## Warning: Removed 11 rows containing missing values (`geom_line()`).
In the TuktuTools
package, we added a function that
allows to easily compute kernel utilization distributions, in one line
of code: getKernelUD
. This function uses the function
kernelUD
from the adehabitatHR
package, and
thus has the same parameters found in the kernelUD
function.
individuals_kernel <- caribou_daily_mean %>%
st_as_sf(coords=c("x", "y"), crs = 32610) %>%
ddply(c("ID","Year"), getKernelUD, extent = 10) %>%
st_as_sf(crs = 32610)
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
## that
head(individuals_kernel)
## Simple feature collection with 6 features and 4 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 51181.27 ymin: 7125049 xmax: 419304.2 ymax: 7385712
## Projected CRS: WGS 84 / UTM zone 10N
## ID Year id area geometry
## 1 Dancer 2002 homerange 12188602525 POLYGON ((113142.5 7241814,...
## 2 Dancer 2003 homerange 48483706527 POLYGON ((79139.69 7205536,...
## 3 Dancer 2004 homerange 21657374195 POLYGON ((107241.3 7233415,...
## 4 Prancer 2014 homerange 11318075672 POLYGON ((106989.8 7258670,...
## 5 Prancer 2015 homerange 11568424749 POLYGON ((96700.08 7229964,...
## 6 Prancer 2016 homerange 29417123198 POLYGON ((99316.73 7241306,...
# visualize
mapview::mapview(individuals_kernel, zcol = "ID")
We also added the getLoCoH
function, which allows to
compute Local Convex Hull (LoCoH). Read more about these here: http://tlocoh.r-forge.r-project.org/. In short, these
are known to perform better than parametric kernel methods, in the
context of estimating the size of home ranges and delineating geological
and ecological features in home ranges.
The LoCoH method is both a generalization of the minimum convex polygon (MCP) method and essentially a non-parametric kernel method. LoCoH applies the MCP construction to a subset of data localized in space, and the local convex polygon (i.e. local hull) is constructed using a specific number of nearest neighbors (nn) of each data point, thereby producing a set of nonparametric kernels whose union is the UD.
One advantage of using LoCoH is that this method allows to consider avoided areas (or holes) in ranges.
One complication of using this method is that you need to install the
tlocoh
package which is not on CRAN, but on another
repository.
To install T-LoCoH, type one of the following commands below at the R console. If you get stuck, see the steps for manual installation.
# Windows:
install.packages("tlocoh", dependencies=TRUE, repos=c("http://R-Forge.R-project.org", "http://cran.cnr.berkeley.edu"))
require(tlocoh)
# Mac / LINUX:
install.packages("tlocoh", dependencies=TRUE, repos=c("http://R-Forge.R-project.org", "http://cran.cnr.berkeley.edu"), type="source")
require(tlocoh)
The following code will estimate the local convex hull estimate range of animals of day of year.
individuals_locoh <- caribou_sf %>%
ddply(c("ID","Year"), getLoCoH, nn = 30)
## Warning in tlocoh::xyt.lxy(xy = xy, id = 1, proj4string = CRS(raster::projection(sf))): Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=2468), num.parent.pts=2468,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n2468|kmax30|rmax0|amax0.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n2468|kmax30|rmax0|amax0.1
## Total time: 0.1 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts2468.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts2468.k30.s0.kmin0
## Total time: 0.7 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=1771), num.parent.pts=1771,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n1771|kmax30|rmax0|amax0.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n1771|kmax30|rmax0|amax0.1
## Total time: 0.1 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 1 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts1771.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts1771.k30.s0.kmin0
## Total time: 0.5 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=4116), num.parent.pts=4116,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n4116|kmax30|rmax0|amax0
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n4116|kmax30|rmax0|amax0
## Total time: 0.1 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 33 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts4116.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts4116.k30.s0.kmin0
## Total time: 1.5 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=208), num.parent.pts=208,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n208|kmax30|rmax0|amax0.9
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n208|kmax30|rmax0|amax0.9
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts208.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts208.k30.s0.kmin0
## Total time: 0.1 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=805), num.parent.pts=805,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n805|kmax30|rmax0|amax0.4
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n805|kmax30|rmax0|amax0.4
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts805.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts805.k30.s0.kmin0
## Total time: 0.2 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=1095), num.parent.pts=1095,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n1095|kmax30|rmax0.1|amax1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n1095|kmax30|rmax0.1|amax1
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts1095.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts1095.k30.s0.kmin0
## Total time: 0.3 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=731), num.parent.pts=731,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n731|kmax30|rmax0.1|amax1.4
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n731|kmax30|rmax0.1|amax1.4
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts731.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts731.k30.s0.kmin0
## Total time: 0.2 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=824), num.parent.pts=824,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n824|kmax30|rmax0|amax0.2
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n824|kmax30|rmax0|amax0.2
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts824.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts824.k30.s0.kmin0
## Total time: 0.2 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=1103), num.parent.pts=1103,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n1103|kmax30|rmax0|amax0.7
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n1103|kmax30|rmax0|amax0.7
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 5 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts1103.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts1103.k30.s0.kmin0
## Total time: 0.4 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=593), num.parent.pts=593,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n593|kmax30|rmax0|amax0.3
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n593|kmax30|rmax0|amax0.3
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 7 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts593.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts593.k30.s0.kmin0
## Total time: 0.2 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=1675), num.parent.pts=1675,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n1675|kmax30|rmax0|amax0.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n1675|kmax30|rmax0|amax0.1
## Total time: 0.1 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 1 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts1675.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts1675.k30.s0.kmin0
## Total time: 0.5 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=2409), num.parent.pts=2409,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n2409|kmax30|rmax0|amax0.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n2409|kmax30|rmax0|amax0.1
## Total time: 0.1 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 8 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts2409.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts2409.k30.s0.kmin0
## Total time: 0.7 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: Your data appear to be in geographic coordinates (latitude-longitude).
## You can use T-LoCoH with geographic coordinates, but it isn't
## recommended because length and area in degrees are not meaningful.
## Consider projecting your data to a planar coordinate system with
## lxy.reproject().
## Finding nearest neighbors for id=1 (n=276), num.parent.pts=276,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n276|kmax30|rmax0|amax0.4
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n276|kmax30|rmax0|amax0.4
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
## 1: 1 duplicate points were randomly displaced by 1 map unit(s)
##
## 1.pts276.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts276.k30.s0.kmin0
## Total time: 0.4 secs
## Warning: GEOS support is provided by the sf and terra packages among others
#head(individuals_locoh)
# visualize
mapview::mapview(individuals_locoh %>% st_as_sf, zcol = "ID")
The default number of nearest neighbors in the getLoCoH
function as been set to 10. However, it is worth noting that the
resulting area is sensitive to the number of nearest neighbors chosen
when computing the Local Convex Hulls (LoCoH). We recommend trying
different numbers of nearest neighbors to compute ranges.
Let’s try here with a bigger number of nearest neighbors:
individuals_locoh2 <- caribou_daily_mean %>% st_as_sf(coords=c("x", "y"), crs = 32610) %>%
ddply(c("ID","Year"), getLoCoH, nn = 30) %>% st_as_sf(crs = 32610)
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax37897.9|amax481086.3
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax37897.9|amax481086.3
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax62394.3|amax1152744.6
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax62394.3|amax1152744.6
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=48), num.parent.pts=48,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n48|kmax30|rmax25619.5|amax428990.9
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n48|kmax30|rmax25619.5|amax428990.9
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts48.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts48.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax33552|amax596403.8
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax33552|amax596403.8
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax16571.2|amax274586.9
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax16571.2|amax274586.9
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=48), num.parent.pts=48,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n48|kmax30|rmax44872.4|amax614589.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n48|kmax30|rmax44872.4|amax614589.1
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts48.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts48.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax41397|amax627141.4
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax41397|amax627141.4
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax118843.1|amax1709762.6
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax118843.1|amax1709762.6
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=48), num.parent.pts=48,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n48|kmax30|rmax28279.1|amax407296.2
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n48|kmax30|rmax28279.1|amax407296.2
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts48.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts48.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=49), num.parent.pts=49,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n49|kmax30|rmax31359.3|amax479539.1
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n49|kmax30|rmax31359.3|amax479539.1
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts49.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts49.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Finding nearest neighbors for id=1 (n=48), num.parent.pts=48,
## mode=Fixed-k, k=30, s=0, method=Euclidean
## - computing values of kmax, rmax, and amax...Done
## - set of neighbors (re)named: 1|vmax|s0|n48|kmax30|rmax68101.8|amax1050730.6
##
## Done. Nearest neighbor set(s) created / updated:
## 1|vmax|s0|n48|kmax30|rmax68101.8|amax1050730.6
## Total time: 0 secs
## Using nearest-neighbor selection mode: Fixed-k
## Constructing hulls and hull metrics...
##
## 1.pts48.k30.s0.kmin0
## Found a suitable set of nearest neighbors
## Identifying the boundary points for each parent point
## Converting boundary points into polygons
## Calculating area and perimeter...Done.
## The following hullsets were generated:
## 1.pts48.k30.s0.kmin0
## Total time: 0 secs
## Warning: GEOS support is provided by the sf and terra packages among others
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
## that
head(individuals_locoh2)
## Simple feature collection with 6 features and 9 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 101054.8 ymin: 7199165 xmax: 373624 ymax: 7342216
## Projected CRS: WGS 84 / UTM zone 10N
## ID Year iso.level area edge.len nep ptp hm.val num.hulls
## 1 Dancer 2002 0.95 3435319719 287122.1 48 0.9795918 2228207540 33
## 2 Dancer 2003 0.95 7696562183 590162.2 49 1.0000000 4976889697 38
## 3 Dancer 2004 0.95 5795861390 390309.7 46 0.9583333 4496207575 41
## 4 Prancer 2014 0.95 3705011389 274058.1 47 0.9591837 2327582610 31
## 5 Prancer 2015 0.95 2847761237 290603.4 48 0.9795918 2545937038 42
## 6 Prancer 2016 0.95 8546771254 525972.7 48 1.0000000 6014727135 42
## geometry
## 1 POLYGON ((210809.3 7283850,...
## 2 POLYGON ((343640.7 7311865,...
## 3 POLYGON ((219927.8 7328265,...
## 4 POLYGON ((186191.4 7338714,...
## 5 POLYGON ((220916.8 7311578,...
## 6 POLYGON ((233972.4 7327925,...
# visualize
mapview::mapview(individuals_locoh2, zcol = "ID")
We can see that the more nearest neighbors, the less sensitive the method to areas that are actively avoided.