Learn R Programming

camtrapR (version 0.97.0)

recordDatabase: Generate a species record database

Description

Generates a record database from a folder structure of camera trap images (station/species). Within each station directory, all images need to be sorted into species subdirectories.

Usage

recordDatabase(inDir, 
  includeCameras = FALSE, 
  exclude, 
  minDeltaTime = 0, 
  timeZone, 
  writecsv = FALSE, 
  outDir,
  metadataTags
)

Arguments

inDir
character. Directory containing station directories with renamed and identified images in species subdirectories
includeCameras
logical. Should function try to derive camera ID from image names? Requires images renamed with imageRename.
exclude
character vector of species names to be excluded from the record database
minDeltaTime
numeric. time difference between observation of the same species at the same station to be considered independent (in minutes)
timeZone
character. timeZone must be an argument of OlsonNames
writecsv
logical. Should the record database be saved as a .csv?
outDir
character. Directory to save csv to. If NULL and writecsv = TRUE, recordTable will be written to inDir
metadataTags
character. additional camera model-specific metadata tags to be extracted.

Value

  • A data frame containing species records and additional information about stations, date, time and (optionally) further metadata.

Details

minDeltaTime is a criterion for temporal independence of records of a species at the same station/location. Setting it to 0 will make the function return all records. exclude can be used to exclude "species" directories containing irrelavant images (e.g. "team", "blank", "unidentified"). Many digital images contain Exif metadata tags such as "AmbientTemperature" or "MoonPhase" that can be extracted if specified in metadataTags. Because these are manufacturer-specific and not standardized, function exifTagNames provides a vector of all available tag names. Multiple names can be specified as a character vector as: c(Tag1, Tag2, ...). The metadata tags thus extracted may be used as covariates in occupancy modelling.

References

Phil Harvey's Exiftool http://www.sno.phy.queensu.ca/~phil/exiftool/

Examples

Run this code
wd_images_ID <- system.file("pictures/sample_images", package = "camtrapR")
minDeltaT <- 60   # minutes between independent observations

if (Sys.which("exiftool") != ""){        # only run these examples if Exiftool is available

rec.db1 <- recordDatabase(inDir = wd_images_ID,
  minDeltaTime = minDeltaT,
  writecsv = FALSE,
  metadataTags = c("Model", "Make")
)

rec.db2 <- recordDatabase(inDir = wd_images_ID,
  minDeltaTime = minDeltaT,
  exclude = "NO_ID",
  writecsv = FALSE,
  metadataTags = c("Model", "Make")
)

any(rec.db1$Species == "NO_ID")
any(rec.db2$Species == "NO_ID")

} else {                                # show function output if Exiftool is not available
print("Exiftool is not available. Cannot test function")
data(recordDatabaseSample)
}

Run the code above in your browser using DataLab