Learn R Programming

camtrapR (version 0.98.0)

appendSpeciesNames: Add or remove species names from JPEG image filenames

Description

Function to add or remove species names from JPEG image filenames. Images must be sorted into station directories and species subdirectories prior to running the function.

Usage

appendSpeciesNames(inDir, 
  hasCameraSubfolders,
  removeNames = FALSE, 
  writecsv = FALSE
)

Arguments

inDir
character. Directory containing station directories with renamed and identified images in species directories (e.g. inDir/StationA/Species1)
hasCameraSubfolders
logical. Do the station directories contain camera subdirectories (e.g. inDir/StationA/camera1/Species1)?
removeNames
logical. remove appended species names?
writecsv
logical. write csv table containing old and new file names into inDir?

Value

  • A data.frame containing the old and new file names and directories.

Details

Species names can be appended or removed. If species names were appended several times by accident, they can all be removed by running the function with removeNames = TRUE. Before running the function, you may want to run checkSpeciesFolders to detect possible misidentifications. As an example, the function would change an image file name from "StationA__2015-05-41__20-59-59(1).JPG" to "StationA__2015-05-41__20-59-59(1)__Species Name.JPG".

Examples

Run this code
# copy sample images to another location (so we don't mess around in the package directory)
wd_images_ID <- system.file("pictures/sample_images", package = "camtrapR")
file.copy(from = wd_images_ID, to = getwd(), recursive = TRUE)       
wd_images_ID_copy <- paste(getwd(), "sample_images", sep = "/")

# append species names
SpecNameAppend1 <- appendSpeciesNames(inDir       = wd_images_ID_copy,
                                      removeNames = FALSE,
                                      writecsv    = FALSE)
  
SpecNameAppend1

# remove species names
SpecNameRemove1 <- appendSpeciesNames(inDir       = wd_images_ID_copy,
                                      removeNames = TRUE,
                                      writecsv    = FALSE)
  
SpecNameRemove1

Run the code above in your browser using DataLab