Learn R Programming

camtrapR (version 0.98.0)

getSpeciesImages: Copy all images of a species to a new directory

Description

This function will fetch all images of a particular species at all camera trap stations and copies these species' images to a new location. Images must be in the directory structure that is necessary for other functions of this package, too (species subdirectories within station directories). Images should be renamed prior to running the function to give them unique names based on station ID and date/time.

Usage

getSpeciesImages(species, 
  inDir, 
  outDir, 
  stationSubfolders = FALSE
  )

Arguments

species
character. species name for which the images are to be fetched
inDir
Directory in which to look for images. This is the directory containing the station directories, which in turn contain species subdirectories (e.g. inDir/StationA/SpeciesA)
outDir
Directory in which to save species images (in a species subdirectory)
stationSubfolders
logical. within the newly created species directory in outDir, create station directories for images?

Value

  • A data.frame with old and new file locations and the copy status (copy_ok; TRUE if copying was successful).

Details

Before running the function, first rename the images using function imageRename to provide unique file names and prevent several images from having the same name (if generic names like "DCIM0001.jpg" are used). inDir must contain station directories, which in turn contain species image subdirectories of name species.

Examples

Run this code
# define image directory
wd_images_ID <- system.file("pictures/sample_images", package = "camtrapR")
wd_images_ID_copy <- paste(getwd(), "sample_species_images", sep = "/")

species_to_copy <- "VTA"    # = Viverra tangalunga, Malay Civet

specImagecopy <- getSpeciesImages(species           = species_to_copy,
                                  inDir             = wd_images_ID,
                                  outDir            = wd_images_ID_copy,
                                  stationSubfolders = FALSE,
                                  emptyOutDir       = FALSE
  )

Run the code above in your browser using DataLab