The goal of animalImageRetrieval is to enable quick download of reptile images from online sources.
Download the entire repo and use targets::tar_source() to load all R functions in the R folder into your environment.
You may be able to install the development version of animalImageRetrieval from GitHub with:
# install.packages("devtools")
devtools::install_github("BenMMarshall/animalImageRetrieval")
You will need an API keyy from Flickr to run any of the Flickr-related functions, as well as the overall targets pipeline. You can remove the Flickr related sections in the _targets.R file to run the pipeline otherwise.
library(here)
library(dplyr)
library(readr)
library(spocc)
library(targets)
# loads in all the custom functions
targets::tar_source()
# reads in the reptile database file inlcuded and filters it so we aren't searching for everything
reptileData <- animalImageRetrieval::read_reptile_data(orderFilter = "Serpentes",
familyFilter = NULL,
speciesFilter = NULL)
# we create a list to store each result of the inat searches, one object per
# family so if there is a failure we will only lose less than a family of
# progress
snakeResultsList <- vector("list", length = length(unique(reptileData$Family)))
names(snakeResultsList) <- unique(reptileData$Family)
# loop through family my family getting the results for the first 50 inat observations
for(fam in unique(reptileData$Family)){
snakeResultsList[[fam]] <- get_urls_inat(reptileData = reptileData,
subset = fam,
inatLimit = 50)
}
You can use targets::tar_visnetwork() to see the planned workflow for mass downloading images, and targets::tar_make() to run that. Ensure all packages listed in the _targets.R file are present.