Skip to contents

Summarize information about cameras activity from camera trap data.

Usage

summarize_cameras(
  dfrec,
  cam_col,
  datetime_col = NULL,
  date_col = NULL,
  time_col = NULL,
  spp_col = NULL,
  obstype_col = NULL,
  dfcam = NULL,
  cam_col_dfcam = ifelse(is.null(dfcam), NULL, cam_col),
  setup_col = NULL,
  retrieval_col = NULL
)

Arguments

dfrec

the records dataframe: must contain the camera names and some infortmation on the pictures sampling time (date and time or datetime).

cam_col

name of the column containing the camera ID

datetime_col

name of the column containing timestamps for the pictures (optional if date_col and time_col are provided)

date_col

name of the column containing date (optional if datetime_col is provided)

time_col

name of the column containing time (optional if datetime_col is provided)

spp_col

name of the species column (optional). If present, the summarry will include the number of species seen on each camera.

obstype_col

name of the observation type column

dfcam

the dataframe of cameras deployments (optional).

cam_col_dfcam

name of the column containing camera ID in dfcam If dfcam is provided but cam_col_dfcam is NULL, it will be set to cam_col.

setup_col

name of the column containing setup date or datetime in dfcam (optional)

retrieval_col

name of the column containing retrieval date or datetime in dfcam (optional)

Value

The summary is returned as a dataframe with the following columns:

  • a column named as cam_col containing the camera ID.

  • sampling_length length of the sampling period in days (computed with the cameraOperation function from the camtrapR package). If setup or retrieval are NA, then sampling_length is NA and if setup and retrieval are the same (e.g. unique picture), sampling_length is zero.

  • pictures: the number of pictures taken with this camera (it is zero if the camera is only in dfcam but not in dfrec).

  • species (present only if spp_col is provided): number of species caught on camera. If obstype_col is provided, species marked as NA in spp_col but which have different values in obs_type are counted as different species.

  • setup containing the start of the sampling for each camera.

  • retrieval containing the end of the sampling for each camera.

  • setup_origin containing the method used to determine the start of the sampling (picture or setup)

  • retrieval_origin containing the method used to determine the end of the sampling (picture or retrieval)

Details

In the final dataframe, the start and the end of the sampling are computed as follows for each camera:

  • if setup and retrieval date are provided in dfcam, then these dates are used for the start and the end of the sampling in the summary.

  • for the cameras for which this information is not provided, it will be replaced with the date of the first or the last picture of the camera. The information on how the start and the end of the sampling were computed is stored in setup_origin and retrieval_origin.

  • if setup and retrieval date are provided via dfcam, setup_origin and retrieval_origin are metadata.

  • else, these columns contain picture.

  • if dfcam is provided but has no setup or retrieval columns, then the cameras will be added but all columns except camera name will be NA. As this function uses the cameraOperation function from the camtrapR package, the camera names may not contain Cam as it is a reserved name in this function.

Examples

# Create synthetic data
records <- data.frame(species = c("pigeon", "mouse", "pigeon", "mouse", "mouse"),
                      stamp = as.POSIXct(c("2022-01-01 10:22:01", "2022-03-01 22:12:01",
                                           "2022-01-02 11:54:33", "2022-01-12 07:14:38", 
                                           "2022-01-22 18:01:34")),
                      camera = c("A", "A", "B", "B", "B"))
cameras <- data.frame(camera = c("A", "B", "C"),
                      setup = as.Date(c(NA, "2021-12-01", "2021-12-01")),
                      retrieval = as.Date(c("2022-03-01", "2022-03-01", NA)))
# Summarize cameras
summarize_cameras(records, 
                  cam_col = "camera", datetime_col = "stamp", 
                  dfcam = cameras, 
                  setup_col = "setup", retrieval_col = "retrieval",
                  spp_col = "species")
#>   camera pictures species sampling_length               setup  retrieval
#> 1      A        2       2          58.568 2022-01-01 10:22:01 2022-03-01
#> 2      B        3       2          90.000 2021-12-01 00:00:00 2022-03-01
#> 3      C        0      NA              NA 2021-12-01 00:00:00       <NA>
#>   setup_origin retrieval_origin
#> 1      picture         metadata
#> 2     metadata         metadata
#> 3     metadata             <NA>
# Since camera A had no setup date, the first picture is used.
# For camera B, setup and retrieval are taken from dfcam.
# For camera C, as it is present only on dfcam and has no retrieval date,
# only a setup date is indicated.