Title: | Camera Trap Monitoring For Estimating Wildlife Density |
---|---|
Description: | Evaluating potential camera trap locations. Potential locations are evaluated using relevant spatial layers producing a dataset of selected locations with covariates that can be used to quantify sampling bias. Soon - density estimation methods. |
Authors: | Alec L. Robitaille [aut, cre] |
Maintainer: | Alec L. Robitaille <[email protected]> |
License: | GPL-3 | file LICENSE |
Version: | 0.12.1 |
Built: | 2024-11-22 04:52:51 UTC |
Source: | https://github.com/robitalec/camtrapmonitoring |
Helper function to make a binary raster layer from input target.
binary_layer(target, fun = "equals", value, layer = 1)
binary_layer(target, fun = "equals", value, layer = 1)
target |
SpatRaster target (see |
fun |
character indicating which function to use to compare layer to value. One of 'equals', 'gt', 'gte', 'lt', 'lte' or 'in'. Default: 'equals'. |
value |
numeric value in target. see Details. |
layer |
default 1, see |
Find all pixels given the function ('fun') matching the value ('value') and return a binary raster.
value' may only be length 1 if 'fun' is one of: 'equals', 'gt', 'gte', 'lt', 'lte'.
'value' may be greater than length 1 only if 'fun' is: 'in'.
A binary raster SpatRaster
(see terra::rast()
) with two values:
TRUE
if pixel matches 'value' provided given the provided function
FALSE
if pixel does not match 'value' provided given the provided function
library(terra) clearwater_lc_path <- system.file("extdata", "clearwater_lake_land_cover.tif", package = "camtrapmonitoring") clearwater_lake_land_cover <- rast(clearwater_lc_path) bin <- binary_layer(target = clearwater_lake_land_cover, fun = 'equals', value = 18) plot(bin) # fun = 'in' bin <- binary_layer(target = clearwater_lake_land_cover, fun = 'in', value = c(1, 2)) plot(bin)
library(terra) clearwater_lc_path <- system.file("extdata", "clearwater_lake_land_cover.tif", package = "camtrapmonitoring") clearwater_lake_land_cover <- rast(clearwater_lc_path) bin <- binary_layer(target = clearwater_lake_land_cover, fun = 'equals', value = 18) plot(bin) # fun = 'in' bin <- binary_layer(target = clearwater_lake_land_cover, fun = 'in', value = c(1, 2)) plot(bin)
Evaluating potential camera trap locations. Potential locations are evaluated using relevant spatial layers producing a dataset of selected locations with covariates that can be used to quantify sampling bias.
Soon - density estimation methods.
Maintainer: Alec L. Robitaille [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/robitalec/camtrapmonitoring/issues
A dataset containing simulated species density near Clearwater Lake, Manitoba.
clearwater_lake_density
clearwater_lake_density
An sf
(see sf::st_sf()
) object with 272 features and 1 variable
"density".
Simulated species density with three levels "High", "Medium", Low" with probabilities 0.1, 0.3, 0.6. Grid size is 2 km x 2 km.
library(sf) data(clearwater_lake_density) plot(clearwater_lake_density)
library(sf) data(clearwater_lake_density) plot(clearwater_lake_density)
A dataset containing elevation near Clearwater Lake, Manitoba.
An external tif file to be read in with terra as a
SpatRaster
object.
Elevation data are from the AWS using the elevatr package
(elevatr::get_elev_raster()
).
The units are meters.
Hollister, J.W. (2022). elevatr: Access Elevation Data from Various APIs. R package version 0.4.2. https://CRAN.R-project.org/package=elevatr/
library(terra) clearwater_elev_path <- system.file("extdata", "clearwater_lake_elevation.tif", package = "camtrapmonitoring") clearwater_lake_elevation <- rast(clearwater_elev_path) plot(clearwater_lake_elevation)
library(terra) clearwater_elev_path <- system.file("extdata", "clearwater_lake_elevation.tif", package = "camtrapmonitoring") clearwater_lake_elevation <- rast(clearwater_elev_path) plot(clearwater_lake_elevation)
A dataset containing the extent near Clearwater Lake, Manitoba.
clearwater_lake_extent
clearwater_lake_extent
An sf
(see sf::st_sf()
) object with 2 points.
library(sf) data(clearwater_lake_extent) plot(clearwater_lake_extent)
library(sf) data(clearwater_lake_extent) plot(clearwater_lake_extent)
A dataset containing hydrology features (in this case, major lakes) near Clearwater Lake, Manitoba.
clearwater_lake_hydro
clearwater_lake_hydro
An sf
(see sf::st_sf()
) object with 5 features and 8 fields.
See the source below for details.
Hydrology features are from Open Street Map, downloaded using the osmdata package.
Mark Padgham, Bob Rudis, Robin Lovelace, Maëlle Salmon (2017). “osmdata.” Journal of Open Source Software, 2(14), 305. doi:10.21105/joss.00305 https://doi.org/10.21105/joss.00305, https://joss.theoj.org/papers/10.21105/joss.00305.
library(sf) data(clearwater_lake_hydro) plot(clearwater_lake_hydro)
library(sf) data(clearwater_lake_hydro) plot(clearwater_lake_hydro)
A dataset containing land cover classes near Clearwater Lake, Manitoba.
An external tif file to be read in with terra as a SpatRaster
object (see terra::rast()
). See the source below for details.
Land cover data are from 2020 Land Cover of Canada. Class index defined here https://drive.google.com/file/d/1TvOZdLO_N86HfsiJQtnE3BdfAFL1s0ux/view?usp=sharing
1 Temperate or sub-polar needleleaf forest/Forêt de conifères sempervirente tempérée ou subpolaire
2 Sub-polar taiga needleleaf forest/ Forêt de conifères (taïga) subpolaire
5 Temperate or sub-polar broadleaf deciduous forest/ Forêt feuillue tempérée ou subpolaire
6 Mixed forest/ Forêt mixte
8 Temperate or sub-polar shrubland/Arbustaie tempérée ou subpolaire
10 Temperate or sub-polar grassland/Prairie tempérée ou subpolaire
11 Sub-polar or polar shrubland-lichen-moss/Arbustaie à lichens et à mousses polaire ou subpolaire
12 Sub-polar or polar grassland-lichen-moss/Prairie à lichens et à mousses polaire ou subpolaire
13 Sub-polar or polar barren-lichen-moss/Lande à lichens et à mousses polaire ou subpolaire
14 Wetland/Milieu humide
15 Cropland/Terre cultivée
16 Barren Lands/Lande
17 Urban and built-up/Milieu urbain
18 Water/Eau
19 Snow and Ice/Neige et glace
https://open.canada.ca/data/en/dataset/ee1580ab-a23d-4f86-a09b-79763677eb47
library(terra) clearwater_lc_path <- system.file("extdata", "clearwater_lake_land_cover.tif", package = "camtrapmonitoring") clearwater_lake_land_cover <- rast(clearwater_lc_path) plot(clearwater_lake_land_cover)
library(terra) clearwater_lc_path <- system.file("extdata", "clearwater_lake_land_cover.tif", package = "camtrapmonitoring") clearwater_lake_land_cover <- rast(clearwater_lc_path) plot(clearwater_lake_land_cover)
A dataset containing roads near Clearwater Lake, Manitoba.
clearwater_lake_roads
clearwater_lake_roads
An sf
(see sf::st_sf()
) object with 172 roads and 48 variables.
See the source below for details.
Roads are from the Canadian National Road Network (NRN) with all corresponding fields.
https://open.canada.ca/data/en/dataset/3d282116-e556-400c-9306-ca1a3cada77f
library(sf) data(clearwater_lake_roads) plot(clearwater_lake_roads)
library(sf) data(clearwater_lake_roads) plot(clearwater_lake_roads)
A dataset containing wetland features near Clearwater Lake, Manitoba.
clearwater_lake_wetlands
clearwater_lake_wetlands
An sf
(see sf::st_sf()
) object with 5 features and 8 fields.
See the source below for details.
Hydrology features are from Open Street Map, downloaded using the osmdata package.
Mark Padgham, Bob Rudis, Robin Lovelace, Maëlle Salmon (2017). “osmdata.” Journal of Open Source Software, 2(14), 305. doi:10.21105/joss.00305 https://doi.org/10.21105/joss.00305, https://joss.theoj.org/papers/10.21105/joss.00305.
library(sf) data(clearwater_lake_wetlands) plot(clearwater_lake_wetlands)
library(sf) data(clearwater_lake_wetlands) plot(clearwater_lake_wetlands)
Using buffered camera trap locations generated with camtrapmonitoring
functions sample_ct()
and grid_ct()
, sample raster layers to
characterize and select camera trap locations, and quantify potential
sampling bias.
eval_buffer(features, target, buffer_size, buffer_fun = mean, layer = 1)
eval_buffer(features, target, buffer_size, buffer_fun = mean, layer = 1)
features |
sf features (see |
target |
SpatRaster target (see |
buffer_size |
radius of buffer around each point |
buffer_fun |
function for summarizing buffer region, default mean |
layer |
default 1, see |
vector of values from target matching buffered locations in features
Other eval:
eval_dist()
,
eval_pt()
library(terra) data("clearwater_lake_density") clearwater_lake_elevation <- rast(system.file('extdata', 'clearwater_lake_elevation.tif', package = 'camtrapmonitoring')) # Sample points pts <- sample_ct(region = clearwater_lake_density, 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$elev <- eval_buffer( features = queen, target = clearwater_lake_elevation, buffer_size = 150) plot(queen["elev"])
library(terra) data("clearwater_lake_density") clearwater_lake_elevation <- rast(system.file('extdata', 'clearwater_lake_elevation.tif', package = 'camtrapmonitoring')) # Sample points pts <- sample_ct(region = clearwater_lake_density, 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$elev <- eval_buffer( features = queen, target = clearwater_lake_elevation, buffer_size = 150) plot(queen["elev"])
Using camera trap locations generated with camtrapmonitoring
functions sample_ct()
and grid_ct()
, evalaute the distance between
features and camera trap locations to characterize and select locations,
and quantify potential sampling bias.
eval_dist(features, target, measure = NULL)
eval_dist(features, target, measure = NULL)
features |
sf features (see |
target |
sf feature target (see |
measure |
measure type see |
To avoid the large overhead of creating distance to rasters for small/medium
number of sample points, this function uses the vector-based distance
approach from distanceto::distance_to()
. It determines the
nearest feature to each target then calculates the distance between
each pair.
vector of distances between target and features
Other eval:
eval_buffer()
,
eval_pt()
data("clearwater_lake_density") data("clearwater_lake_wetlands") # Sample points pts <- sample_ct(region = clearwater_lake_density, 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$dist_wetland <- eval_dist(features = queen, target = clearwater_lake_wetlands) # Plot plot(queen["dist_wetland"])
data("clearwater_lake_density") data("clearwater_lake_wetlands") # Sample points pts <- sample_ct(region = clearwater_lake_density, 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$dist_wetland <- eval_dist(features = queen, target = clearwater_lake_wetlands) # Plot plot(queen["dist_wetland"])
Using camera trap locations generated with camtrapmonitoring
functions sample_ct()
and grid_ct()
, sample raster layers to
characterize and select camera trap locations, and quantify potential
sampling bias.
eval_pt(features, target, layer = 1)
eval_pt(features, target, layer = 1)
features |
sf features (see |
target |
SpatRaster target (see |
layer |
default 1, see |
vector of values from target matching locations in features
Other eval:
eval_buffer()
,
eval_dist()
library(terra) data("clearwater_lake_density") clearwater_lake_land_cover <- rast(system.file('extdata', 'clearwater_lake_land_cover.tif', package = 'camtrapmonitoring')) # Sample points pts <- sample_ct(region = clearwater_lake_density, n = 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$lc <- eval_pt(features = queen, target = clearwater_lake_land_cover) plot(queen["lc"])
library(terra) data("clearwater_lake_density") clearwater_lake_land_cover <- rast(system.file('extdata', 'clearwater_lake_land_cover.tif', package = 'camtrapmonitoring')) # Sample points pts <- sample_ct(region = clearwater_lake_density, n = 1, type = 'random') # Make grid with queen's case queen <- grid_ct(features = pts, case = 'queen', distance = 100) # Evaluate each point with the land cover layer queen$lc <- eval_pt(features = queen, target = clearwater_lake_land_cover) plot(queen["lc"])
Set up grids around focal points. For example, sample points in your study
area with sample_ct()
then use grid_ct()
to establish a grid of camera
traps around each.
grid_ct(features, distance, case, n, id = "id_sample_ct")
grid_ct(features, distance, case, n, id = "id_sample_ct")
features |
sf features (see |
distance |
distance between adjacent camera traps. Don't worry about the hypotenuse. |
case |
"queen", "rook", "bishop", or "triplet". Ignored if |
n |
number of points around each focal point. |
id |
default: "id_sample_ct" generated automatically from |
Extended sf object either nine times the length of input features for 'queen' case or 5 times the length of input DT for 'rook' or 'bishop' case. Otherwise n * number the length of input features. See examples.
The logical 'focal' column indicates which point is the focal camera trap for each grid.
Other grid:
grid_design()
data("clearwater_lake_density") pts <- sample_ct(clearwater_lake_density, 1, type = 'random') # Make grid with case, eg. 'queen' queen <- grid_ct(features = pts, distance = 100, case = 'queen') # Plot plot(queen['focal']) # Make grid with n n_grid <- grid_ct(features = pts, distance = 100, n = 25) plot(n_grid['id_grid_ct'])
data("clearwater_lake_density") pts <- sample_ct(clearwater_lake_density, 1, type = 'random') # Make grid with case, eg. 'queen' queen <- grid_ct(features = pts, distance = 100, case = 'queen') # Plot plot(queen['focal']) # Make grid with n n_grid <- grid_ct(features = pts, distance = 100, n = 25) plot(n_grid['id_grid_ct'])
Helper function used internally by grid_ct()
to establish grids around
focal locations. Provided to the user to explore grid design options before
applying to their data.
grid_design(distance, case, n)
grid_design(distance, case, n)
distance |
distance between adjacent camera traps. Don't worry about the hypotenuse. |
case |
"queen", "rook", "bishop", or "triplet". Ignored if |
n |
number of points around each focal point. |
grid design data.frame
Other grid:
grid_ct()
plot(grid_design(distance = 100, case = 'queen')) plot(grid_design(distance = 100, n = 13))
plot(grid_design(distance = 100, case = 'queen')) plot(grid_design(distance = 100, n = 13))
Sample potential camera trap locations. For stratified sampling, provide a
suitable column to stratify region by. Alternatively, sf::st_sample()
is used directly to sample points across all features.
sample_ct(region, n, type, strata = NULL)
sample_ct(region, n, type, strata = NULL)
region |
spatial feature object across which points will be sampled |
n |
number of random points. If |
type |
type of sampling, see |
strata |
column name in region indicating strata |
sf
(see sf::st_sf()
) object with POINT geometry
# Example grid with density levels (High, Medium, Low) data(clearwater_lake_density) # Stratified random points for each density level pts_random <- sample_ct( region = clearwater_lake_density, n = 20, type = 'random', strata = 'density') # Plot density grid and sampled points plot(clearwater_lake_density, reset = FALSE) plot(pts_random, add = TRUE, pch = 1, strata = 1) # Regular sampled points across all features pts_regular <- sample_ct( region = clearwater_lake_density, n = 20, type = 'regular') # Plot density grid and sampled points plot(clearwater_lake_density, reset = FALSE) plot(pts_regular, add = TRUE, pch = 2, strata = 1)
# Example grid with density levels (High, Medium, Low) data(clearwater_lake_density) # Stratified random points for each density level pts_random <- sample_ct( region = clearwater_lake_density, n = 20, type = 'random', strata = 'density') # Plot density grid and sampled points plot(clearwater_lake_density, reset = FALSE) plot(pts_random, add = TRUE, pch = 1, strata = 1) # Regular sampled points across all features pts_regular <- sample_ct( region = clearwater_lake_density, n = 20, type = 'regular') # Plot density grid and sampled points plot(clearwater_lake_density, reset = FALSE) plot(pts_regular, add = TRUE, pch = 2, strata = 1)
Helper function to scale a target layer in a region of interest.
Can be used to compare locations with eval_pt()
and eval_buffer()
,
and select locations based off of relative values instead of absolute values.
scale_layer(target, region, center = TRUE, scale = TRUE)
scale_layer(target, region, center = TRUE, scale = TRUE)
target |
SpatRaster target (see |
region |
object which can be passed to |
center |
see |
scale |
see |
SpatRaster
layer, cropped to extent of provided region, and scaled.
# Load packages library(terra) # Load data data("clearwater_lake_hydro") clearwater_elev_path <- system.file( "extdata", "clearwater_lake_elevation.tif", package = "camtrapmonitoring") clearwater_lake_elevation <- rast(clearwater_elev_path) # Region of interest around Clearwater lake roi <- clearwater_lake_hydro[4,] # Scale elevation in extent of density grid elev_scaled <- scale_layer(target = clearwater_lake_elevation, region = roi)
# Load packages library(terra) # Load data data("clearwater_lake_hydro") clearwater_elev_path <- system.file( "extdata", "clearwater_lake_elevation.tif", package = "camtrapmonitoring") clearwater_lake_elevation <- rast(clearwater_elev_path) # Region of interest around Clearwater lake roi <- clearwater_lake_hydro[4,] # Scale elevation in extent of density grid elev_scaled <- scale_layer(target = clearwater_lake_elevation, region = roi)