| Title: | Density Estimation Functions for camtrapDP Data |
|---|---|
| Description: | Currently provides functions for working with camtrapDP format data exported from Agouti - checking deployment calibration diagnostic plots, filtering deployments, correcting mis-specified date-time data at specific deployments, running REM density analysis. |
| Authors: | Marcus Rowcliffe |
| Maintainer: | Marcus Rowcliffe <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.16 |
| Built: | 2026-07-02 05:32:38 UTC |
| Source: | https://github.com/MarcusRowcliffe/camtrapDensity |
Displays deployment calibration model diagnostic plots and allows users to record interactively whether each deployment is reliable.
check_deployment_models(package)check_deployment_models(package)
package |
Camera trap data package object, as returned by
|
The original package with logical column useDeployment'
added to deployments and observations data.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") pkg_checked <- check_deployment_models(pkg) ## End(Not run)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") pkg_checked <- check_deployment_models(pkg) ## End(Not run)
Changes the units of parameters from their current setting to new user-defined units.
convert_units( param, radius_unit = c("km", "m", "cm"), angle_unit = c("radian", "degree"), active_speed_unit = c("km/day", "km/hour", "m/hour", "m/second"), overall_speed_unit = c("km/day", "km/hour", "m/hour", "m/second"), trap_rate_unit = c("n/day", "n/100day", "n/hour", "n/minute", "n/second"), density_unit = c("n/km2", "n/ha", "n/100km2") )convert_units( param, radius_unit = c("km", "m", "cm"), angle_unit = c("radian", "degree"), active_speed_unit = c("km/day", "km/hour", "m/hour", "m/second"), overall_speed_unit = c("km/day", "km/hour", "m/hour", "m/second"), trap_rate_unit = c("n/day", "n/100day", "n/hour", "n/minute", "n/second"), density_unit = c("n/km2", "n/ha", "n/100km2") )
param |
An REM parameter dataframe (see details). |
radius_unit |
A character string giving the output unit of radius. |
angle_unit |
A character string giving the output unit of angle. |
active_speed_unit |
A character string giving the output unit of speed while active. |
overall_speed_unit |
A character string giving the output unit of day range. |
trap_rate_unit |
A character string giving the output unit of trap rate. |
density_unit |
A character string giving the output unit of density. |
Input dataframe param must contain field unit, and at least one
field among estimate, se, lcl95, and ucl95.
Row names must be among radius, angle, activity_level,
active_speed, overall_speed. Input is typically created with
function get_parameter_table.
A replica of input dataframe param with estimate,
se and confidence limit values converted to output units.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) param <- get_parameter_table(trdata, radmod, angmod, spdmod, actmod) convert_units(param, radius_unit="m", angle_unit="degree", active_speed_unit="m/second")## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) param <- get_parameter_table(trdata, radmod, angmod, spdmod, actmod) convert_units(param, radius_unit="m", angle_unit="degree", active_speed_unit="m/second")
When a camera trap starts with the wrong time stamp, times in all datapackage tables can be corrected given a reference time recorded by the camera, the correct time for this reference time and the ID of the deployment to correct.
correct_time(package, depID = NULL, locName = NULL, wrongTime, rightTime)correct_time(package, depID = NULL, locName = NULL, wrongTime, rightTime)
package |
Camera trap data package object, as returned by
|
depID |
A character value giving the deployment ID, to be matched in package$data$deployments$deploymentID. |
locName |
A character value giving the location name, to be matched in package$data$deployments$locationName. |
wrongTime |
A character or POSIX reference date-time recorded wrongly by the camera. |
rightTime |
A character or POSIX value giving the correct date-time when the reference time was recorded. |
One, but not both, of depID and locName must be provided, as single text values. If locName is provided, the deployment associated with this in pkg$data$deployments is corrected, but if locName is associated with more than one deployment the function does not run.
As for read_camtrap_dp, with all
date-times corrected by the difference between rightTime and wrongTime.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) pkg_corrected <- correct_time(pkg, locName = "S01", wrongTime = "2017-10-02 08:06:43", rightTime = "2017-09-01 10:36:00")## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) pkg_corrected <- correct_time(pkg, locName = "S01", wrongTime = "2017-10-02 08:06:43", rightTime = "2017-09-01 10:36:00")
Downversions a Cmatrap DP datapackage to V0 by duplicating dataframe fields whose names differ between versions with V0 fields created in addition to existing V1 fields.
downversion_camtrapDP(pkg)downversion_camtrapDP(pkg)
pkg |
Camera trap data package list, as returned by
|
A duplicate of the original package with the addition of duplicate of fields with V0 fieldnames to data.
## Not run: pkgV0 <- downversion_camtrapDP(pkgV1)## Not run: pkgV0 <- downversion_camtrapDP(pkgV1)
Fits an activity model to data package data and estimates activity level (proportion of time spent active).
fit_actmodel( package, species = NULL, reps = 999, obsdef = c("individual", "sequence"), ... )fit_actmodel( package, species = NULL, reps = 999, obsdef = c("individual", "sequence"), ... )
package |
Camera trap data package object, as returned by
|
species |
A character string indicating species subset to analyse; if NULL runs select_species to get user input. |
reps |
Number of bootstrap replicates to run. |
obsdef |
Observation definition, either individual or sequence. |
... |
Arguments passed to |
An 'actmod' list.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition act_model <- fit_actmodel(pkg) ## End(Not run) # With species predefined, reps reduced for speed act_model <- fit_actmodel(pkg, species="Vulpes vulpes", reps=100) act_model@act## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition act_model <- fit_actmodel(pkg) ## End(Not run) # With species predefined, reps reduced for speed act_model <- fit_actmodel(pkg, species="Vulpes vulpes", reps=100) act_model@act
Fits a detection function to a data package and estimates effective detection distance (EDD).
fit_detmodel( formula, package, species = NULL, newdata = NULL, unit = c("m", "km", "cm", "degree", "radian"), ... )fit_detmodel( formula, package, species = NULL, newdata = NULL, unit = c("m", "km", "cm", "degree", "radian"), ... )
formula |
A two sided formula relating radius or angle data to covariates. |
package |
Camera trap data package object, as returned by
|
species |
A character string indicating species subset to analyse; if NULL runs select_species to get user input; if "all" all data are used. |
newdata |
A dataframe of covariate values at which to predict detection distance. |
unit |
The units in which to return the result. |
... |
Arguments passed to |
The type of detection function (line or point) is determined by
the unit argument.
A ddf detection function model list, with additional elements:
edd, a vector with estimated and standard error effective detection
distance, or the newdata dataframe with EDD estimate and se
columns added;
proportion_used, the proportion of the observations used to fit the
detection function in the case of truncation.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition radius_model <- fit_detmodel(radius~1, pkg, order=0) ## End(Not run) # With species predefined sp <- "Vulpes vulpes" radius_model <- fit_detmodel(radius~1, pkg, species=sp, order=0) angle_model <- fit_detmodel(angle~1, pkg, species=sp, order=0, unit="degree") radius_model$edd angle_model$edd plot(radius_model, pdf=TRUE) plot(angle_model)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition radius_model <- fit_detmodel(radius~1, pkg, order=0) ## End(Not run) # With species predefined sp <- "Vulpes vulpes" radius_model <- fit_detmodel(radius~1, pkg, species=sp, order=0) angle_model <- fit_detmodel(angle~1, pkg, species=sp, order=0, unit="degree") radius_model$edd angle_model$edd plot(radius_model, pdf=TRUE) plot(angle_model)
Calculates harmonic mean and standard error of animal speed while active from a data package.
fit_speedmodel( package, species = NULL, formula = speed ~ 1, newdata = NULL, reps = 1000, distUnit = c("m", "km", "cm"), timeUnit = c("second", "minute", "hour", "day"), ... )fit_speedmodel( package, species = NULL, formula = speed ~ 1, newdata = NULL, reps = 1000, distUnit = c("m", "km", "cm"), timeUnit = c("second", "minute", "hour", "day"), ... )
package |
Camera trap data package object, as returned by
|
species |
A character string indicating species subset to analyse; if NULL runs select_species to get user input; if all uses all data. |
formula |
A formula with speed on the left and covariates on the right. |
newdata |
A data frame of covariate values at which to predict speeds. |
reps |
Number of random draws to use for standard calculation. |
distUnit |
A character string indicating distance unit of speed observations. |
timeUnit |
A character string indicating time unit of speed observations. |
... |
Other parameters passed to |
If a formula is provided, the model is fitted using the sbm
(size biased model) function, which can be installed using:
devtools::source_url("https://raw.githubusercontent.com/MarcusRowcliffe/sbd/master/sbd.r")
List with elements:
speed: a dataframe containing columns estimate
(mean) and se (standard error) speed while active.
data: a numeric vector of the data from which the estimate is derived.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition speed_model <- fit_speedmodel(pkg) ## End(Not run) # With species predefined speed_model <- fit_speedmodel(pkg, species="Vulpes vulpes") speed_model$estimate hist(speed_model)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition speed_model <- fit_speedmodel(pkg) ## End(Not run) # With species predefined speed_model <- fit_speedmodel(pkg, species="Vulpes vulpes") speed_model$estimate hist(speed_model)
Obtains web addresses for sequences of selected observations, based on criteria defined using fields in the observations table.
get_agouti_url(package, obsChoice)get_agouti_url(package, obsChoice)
package |
Camera trap data package object, as returned by
|
obsChoice |
A logical expression using column names from the observations table defining which observations you want to inspect. |
A dataframe of Agouti URLs.
data(pkg) get_agouti_url(pkg, speed>1)data(pkg) get_agouti_url(pkg, speed>1)
Returns a multiplier to convert values from one unit to another, in one of four categories: distance, time, angle, count.
get_multiplier(unitIN, unitOUT)get_multiplier(unitIN, unitOUT)
unitIN |
A character vector giving the units of input. |
unitOUT |
A character vector giving the units of output,
the same length as |
Possible unitIN and unitOUT values are "cm", "m", "km"
for distances; "second", "minute", "hour", "day", "100day" for times;
"radian", "degree" for angles; "n" for count; "none" for no units. Unit
ratios are allowed for rates or densities. In this case, units should be
separated with a forward slash (e.g. "n/day", "km/hour", "n/km2"). Input
and output types must match.
A vector of numbers giving the amount by which to multiply input values to arrive at unit-converted values.
get_multiplier(c("m", "m/second"), c("km", "km/day"))get_multiplier(c("m", "m/second"), c("km", "km/day"))
Creates a table of REM parameters taken from models for detection radius, detection angle, speed and activity level.
get_parameter_table( traprate_data, radius_model, angle_model, speed_model, activity_model, strata = NULL, reps = 999 )get_parameter_table( traprate_data, radius_model, angle_model, speed_model, activity_model, strata = NULL, reps = 999 )
traprate_data |
A dataframe of trap rate data (counts and effort), as
returned by |
radius_model |
A detection radius model fitted using |
angle_model |
A detection angle model fitted using |
speed_model |
A speed model fitted using |
activity_model |
An activity model fitted using |
strata |
A dataframe of stratum information passed to |
reps |
Number of bootstrap replicates for estimating trap rate error
(see |
A dataframe of unit-harmonised parameter estimates with rows:
radius: detection radius
angle: detection angle
active_speed: speed while active
activity_level: proportion of time spent active
overall_speed: long-term average speed (day range) - the product
of active_speed and activity_level
trap_rate: number of camera trap records per unit time
and columns
estimate: parameter estimates
se: standard error
cv: proportional coefficient of variation
lcl95, ucl95: lower and upper 95% confidence limits
n: sample size
unit: the unit of the estimate
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) get_parameter_table(trdata, radmod, angmod, spdmod, actmod)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) get_parameter_table(trdata, radmod, angmod, spdmod, actmod)
Calculates average trap rate and its bootstrapped error from a table of per-location observation counts and camera time.
get_trap_rate(traprate_data, strata = NULL, reps = 999)get_trap_rate(traprate_data, strata = NULL, reps = 999)
traprate_data |
A dataframe containing (at least) columns |
strata |
A dataframe with one row per stratum, and columns
|
reps |
The number of bootstrap replicates to run. |
A dataframe with columns:
- estimate: average trap rate
- se: standard error
- cv: proportional coefficient of variation
- lcl95, ucl95: lower and upper 95
- n: sample size (number of locations)
- unit: the unit of the estimate
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) trdata <- get_traprate_data(pkg, species="Vulpes vulpes") get_trap_rate(trdata)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) trdata <- get_traprate_data(pkg, species="Vulpes vulpes") get_trap_rate(trdata)
Extracts a data table of observation counts and effort for each camera location in a camtrap-dp data package.
get_traprate_data( package, species = NULL, unit = c("day", "hour", "minute", "second") )get_traprate_data( package, species = NULL, unit = c("day", "hour", "minute", "second") )
package |
Camera trap data package object, as returned by
|
species |
A character string indicating species subset to extract
data for; if NULL runs |
unit |
The time unit in which to return camera effort. |
A tibble with columns:
locationName: name of the camera location
effort: the camera time for the location
unit: the effort time unit
scientificName: the scientific name of the species data extracted
n: the observation counts
stratumID: stratum identifier (only if this column is present in
package$data$deployments)
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition trdata <- get_traprate_data(pkg) ## End(Not run) # With species predefined trdata <- get_traprate_data(pkg, species="Vulpes vulpes")## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) ## Not run: # With interactive species definition trdata <- get_traprate_data(pkg) ## End(Not run) # With species predefined trdata <- get_traprate_data(pkg, species="Vulpes vulpes")
Calculates approximate log-normal confidence intervals given estimates and their standard errors.
lnorm_confint(estimate, se, percent = 95)lnorm_confint(estimate, se, percent = 95)
estimate |
Numeric estimate value(s) |
se |
Standard error(s) of the estimate |
percent |
Percentage confidence level |
A dataframe with a row per estimate input, and columns lcl
and ucl (lower and upper confidence limits).
lnorm_confint(10.13, 3.57)lnorm_confint(10.13, 3.57)
Creates an OpenStreetMap street or satellite map over-plotted with deployment locations.
map_deployments(pkg, basemap = c("street", "satellite"), ...)map_deployments(pkg, basemap = c("street", "satellite"), ...)
pkg |
Camera trap data package object, as returned by
|
basemap |
Basemap to plot, street (default) or satellite |
... |
Additional arguments passed to
|
## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) map_deployments(pkg)## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) map_deployments(pkg)
Creates an OpenStreetMap street or satellite map over-plotted with deployment locations, with points sized in proportion to trap rate for a given species.
map_traprates( pkg, species = NULL, basemap = c("street", "satellite"), maxSize = 25, minSize = 3 )map_traprates( pkg, species = NULL, basemap = c("street", "satellite"), maxSize = 25, minSize = 3 )
pkg |
Camera trap data package object, as returned by
|
species |
A character string indicating species subset to analyse. Use scientific names. If NULL runs select_species to get user input; if all uses all data. |
basemap |
Basemap to plot, street (default) or satellite |
maxSize |
Maximum point size to plot. |
minSize |
Minimum point size to plot. |
## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) map_traprates(pkg, species="Vulpes vulpes")## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) map_traprates(pkg, species="Vulpes vulpes")
Merges a list of several Camtrap DP datapackages into a single datapackage.
merge_camtrapDP(pkgs)merge_camtrapDP(pkgs)
pkgs |
A list of camera trap data packages, as returned by
|
Original datapackage metadata are stored in named top-level
components of the output list, along with a single data component with
the usual dataframes merged across datapackages, and additional
packageName fields indicating the datapackage from which data row
originates.
A single datapackage with component dataframes merged.
## Not run: bigpkg <- merge_camtrapDP(list(pkg1, pkg2))## Not run: bigpkg <- merge_camtrapDP(list(pkg1, pkg2))
data,
itself a list holding dataframes deployments, media and
observations. See https://tdwg.github.io/camtrap-dp for details.Data and metadata from an example study exported from the Agouti camera trap
data management platform in camtrap-DP format. Metadata includes study name,
authors, location and other details. Data is held in element data,
itself a list holding dataframes deployments, media and
observations. See https://tdwg.github.io/camtrap-dp for details.
A list holding study data and metadata.
Plots an interactive Gantt chart illustrating deployment times (black lines) and the occurrence of observations within those deployments (orange bars). Useful for checking errors in specification of deployment start and end dates, and visualising spatiotemporal distribution of observations.
plot_deployment_schedule(package)plot_deployment_schedule(package)
package |
Camera trap data package object, as returned by
|
## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) plot_deployment_schedule(pkg)## Not run: pkg <- read_camtrapDP("./data/datapackage.json") data(pkg) plot_deployment_schedule(pkg)
Reads csv data from a folder into a list that functions like a camtrap-dp object for the purposes of density estimation.
read_camtrap_dp_csv( folder, tryFormats = c("%Y-%m-%d %H:%M:%OS", "%Y/%m/%d %H:%M:%OS", "%Y:%m:%d %H:%M:%OS") )read_camtrap_dp_csv( folder, tryFormats = c("%Y-%m-%d %H:%M:%OS", "%Y/%m/%d %H:%M:%OS", "%Y:%m:%d %H:%M:%OS") )
folder |
A character string giving the folder in which the csv files sit. |
tryFormats |
A character string defining date-time format, passed to as.POSIXct. |
The folder must contain three csv files: deployments.csv, media.csv and observations.csv, each of which must contain at least the following fields:
deployments: deploymentID, locationID, locationName, longitude, latitude,start,end
media: mediaID, deploymentID, sequenceID, timestamp, filePath, fileName
observations: observationID, deploymentID, sequenceID, mediaID, timestamp, scientificName, count, speed, radius, angle
As for read_camtrap_dp but with reduced
package metadata.
## Not run: pkg <- read_camtrap_dp_csv("./data")## Not run: pkg <- read_camtrap_dp_csv("./data")
Reads the metadata and csv files from a Camtrap DP version 1 datapackage as exported from Agouti.
read_camtrapDP( file, media = TRUE, recalc = TRUE, addV0 = TRUE, dtFormat = "YmdHMSz" )read_camtrapDP( file, media = TRUE, recalc = TRUE, addV0 = TRUE, dtFormat = "YmdHMSz" )
file |
Path to a datapackage.json file. |
media |
Logical defining whether to read media table. |
recalc |
Logical defining whether to recalculate event; if |
addV0 |
Logical defining whether to add camtrapDP version 0 fields, for compatibility with functions using this data model. |
dtFormat |
Character format used to read date-time fields, passed to
|
A list of data package metadata components and a data
component with dataframes: deployments, media,
observations (containing event observations) and positions
(containing media observations). If the media argument is FALSE,
the media component is NULL. The positions may also be NULL
if there are no media observations in the input.
## Not run: pkg <- read_camtrapDP("./data/datapackage.json")## Not run: pkg <- read_camtrapDP("./data/datapackage.json")
Recalculates event observation values (individualPositionRadius, individualPositionAngle, individualSpeed) from media observations.
recalc_events(pkg)recalc_events(pkg)
pkg |
Camera trap data package list, as returned by
|
The process requires media data and fails if this is not
available in the datapackage. The datapackage should also contain
positions data, but the original package is simply returned unmodified if
the positions data table contains no data. In recalculating speeds,
observations with zero time difference (hence infinite speed) impute time
elapsed from average frame rate.
A duplicate of the original package with event observation values recalculated.
## Not run: pkg2 <- recalc_events(pkg2)## Not run: pkg2 <- recalc_events(pkg2)
Estimates REM density given a dataframe of parameters and their errors.
rem(parameters)rem(parameters)
parameters |
A dataframe containing REM parameter estimates with (at least) rows:
and columns:
|
A dataframe with the input parameters plus estimated density and its errors.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) param <- get_parameter_table(trdata, radmod, angmod, spdmod, actmod) rem(param)## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) sp <- "Vulpes vulpes" trdata <- get_traprate_data(pkg, species=sp) radmod <- fit_detmodel(radius~1, pkg, species=sp, order=0) angmod <- fit_detmodel(angle~1, pkg, species=sp, unit="radian", order=0) spdmod <- fit_speedmodel(pkg, species=sp) actmod <- fit_actmodel(pkg, species=sp, reps=100) param <- get_parameter_table(trdata, radmod, angmod, spdmod, actmod) rem(param)
Estimates animal density for a given species given a camtrapDP datapackage.
Models for detection radius and angle, speed and/or activity level can be
fitted externally and provided as arguments, or are fitted internally if not
provided (NULL default). Input units are assumed to be distance in m
and time in seconds.
rem_estimate( package, check_deployments = TRUE, species = NULL, radius_model = NULL, angle_model = NULL, speed_model = NULL, activity_model = NULL, strata = NULL, reps = 999 )rem_estimate( package, check_deployments = TRUE, species = NULL, radius_model = NULL, angle_model = NULL, speed_model = NULL, activity_model = NULL, strata = NULL, reps = 999 )
package |
Camera trap data package object, as returned by
|
check_deployments |
Logical indicating whether to check deployment
calibration model diagnostic plots. If |
species |
A character string indicating species subset to analyse;
if NULL runs |
radius_model |
A detection function model for radii fitted using
|
angle_model |
A detection function model for angles fitted using
|
speed_model |
A speed model fitted using |
activity_model |
An activity model fitted using
|
strata |
A dataframe of stratum areas, passed to |
reps |
Number of bootstrap replicates for error estimation. |
A dataframe containing estimates and their errors for density and all contributing parameters.
# Load data ## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) # Sense check deployment schedules plot_deployment_schedule(pkg) ## Not run: # Sense check deployment calibration model diagnostic plots pkg_checked <- check_deployment_models(pkg) # Fully automated analysis (interactive species definition by default; # reps reduced to limit run time). res <- rem_estimate(pkg_checked, check_deployments=FALSE, reps=100) ## End(Not run) # Automated analysis with species predefined and no deployment checking sp <- "Vulpes vulpes" res <- rem_estimate(pkg, species=sp, check_deployments=FALSE, reps=100) # Inspect results res$estimates # Analysis with radius model fitted separately radmod <- fit_detmodel(radius~1, pkg, species=sp, truncation=15, order=0) res <- rem_estimate(pkg, check_deployments = FALSE, species = sp, radius_model = radmod, reps=100) res$estimates# Load data ## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) # Sense check deployment schedules plot_deployment_schedule(pkg) ## Not run: # Sense check deployment calibration model diagnostic plots pkg_checked <- check_deployment_models(pkg) # Fully automated analysis (interactive species definition by default; # reps reduced to limit run time). res <- rem_estimate(pkg_checked, check_deployments=FALSE, reps=100) ## End(Not run) # Automated analysis with species predefined and no deployment checking sp <- "Vulpes vulpes" res <- rem_estimate(pkg, species=sp, check_deployments=FALSE, reps=100) # Inspect results res$estimates # Analysis with radius model fitted separately radmod <- fit_detmodel(radius~1, pkg, species=sp, truncation=15, order=0) res <- rem_estimate(pkg, check_deployments = FALSE, species = sp, radius_model = radmod, reps=100) res$estimates
Presents a table of species names with observation count for each and allows the user to interactively select one.
select_species(package, species = NULL)select_species(package, species = NULL)
package |
Camera trap data package object, as returned by
|
species |
NULL (default) to select interactively, or character vector
giving either one or more valid species names found within
|
A character vector of one or more scientific species names.
## Not run: pkg <- read_camtrapDP("./data/datapackage.json") select_species(pkg) # If provided, a valid species name is simply passed through select_species(pkg, "Vulpes vulpes") # Providing a species name that isn't found in the data throws an error select_species(pkg, "Vulpes vuppes") ## End(Not run)## Not run: pkg <- read_camtrapDP("./data/datapackage.json") select_species(pkg) # If provided, a valid species name is simply passed through select_species(pkg, "Vulpes vulpes") # Providing a species name that isn't found in the data throws an error select_species(pkg, "Vulpes vuppes") ## End(Not run)
Discards any observations, media, or deployments that fall wholly outside the time range defined by start and end. When start or end are not specified, no slicing is applied to start or end points respectively. Slicing applies to all deployments by default, or can be applied to only a subset of deployments specified by depChoice. The fully default behaviour for this function is therefore to do nothing (the datapackage is returned unchanged).
slice_camtrap_dp( package, start = NULL, end = NULL, depChoice = NULL, suffix = "" )slice_camtrap_dp( package, start = NULL, end = NULL, depChoice = NULL, suffix = "" )
package |
Camera trap data package object, as returned by
|
start, end
|
Single character or POSIXct values defining the time range within which to slice the package. |
depChoice |
A logical expression using column names from the deployments table defining which deployments to slice. |
suffix |
A character value to be added to the package name. |
As for read_camtrap_dp, with all
data tables reduced according to the choice criteria.
## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) # Slicing the whole package to mid October 2017 subpkg <- slice_camtrap_dp(pkg, start = "2017/10/10", end = "2017/10/20") # Slicing only deployments at location "S03" to a specific start time/date subpkg <- slice_camtrap_dp(pkg, start = "2017/10/15 14:30:00", depChoice = locationName=="S03")## Not run: pkg <- read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) # Slicing the whole package to mid October 2017 subpkg <- slice_camtrap_dp(pkg, start = "2017/10/10", end = "2017/10/20") # Slicing only deployments at location "S03" to a specific start time/date subpkg <- slice_camtrap_dp(pkg, start = "2017/10/15 14:30:00", depChoice = locationName=="S03")
Select a subset of deployments from a datapackage defined by a choice based on columns in the deployments table.
subset_deployments(package, choice, suffix = "")subset_deployments(package, choice, suffix = "")
package |
Camera trap data package object, as returned by
|
choice |
A logical expression using column names from the deployments table. |
suffix |
A character value to be added to the package name. |
As for read_camtrap_dp, with all
data tables reduced according to the choice criteria at the deployment
level.
# subset excluding a location and including only October 2017 ## Not run: pkg <- camtraptor::read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) subpkg <- subset_deployments(pkg, locationName != "S01" & start >= as.POSIXct("2017-10-01", tz="UTC") & end <= as.POSIXct("2017-10-31", tz="UTC"))# subset excluding a location and including only October 2017 ## Not run: pkg <- camtraptor::read_camtrapDP("./datapackage/datapackage.json") ## End(Not run) data(pkg) subpkg <- subset_deployments(pkg, locationName != "S01" & start >= as.POSIXct("2017-10-01", tz="UTC") & end <= as.POSIXct("2017-10-31", tz="UTC"))
Writes one or more REM estimate tables to a single csv file, with
identifying columns added for project, datapackage, sampling design,
sampling effort, project location, project dates and species. Input
must be REM analysis object(s) created using rem_estimate.
The resulting file name is taken from the project and current date, and
the file is saved to the working directory.
write_rem_csv(...)write_rem_csv(...)
... |
One or more REM analysis objects, separated by commas. |
None - creates a csv file.
## Not run: foxREM <- rem_estimate(pkg_checked, check_deployments=FALSE, species="Vulpes vulpes") hhogREM <- rem_estimate(pkg_checked, check_deployments=FALSE, species="Erinaceus europaeus") write_rem_csv(foxREM, hhogREM) ## End(Not run)## Not run: foxREM <- rem_estimate(pkg_checked, check_deployments=FALSE, species="Vulpes vulpes") hhogREM <- rem_estimate(pkg_checked, check_deployments=FALSE, species="Erinaceus europaeus") write_rem_csv(foxREM, hhogREM) ## End(Not run)