library(dataverse)
library(dplyr)6 Data from Anthromes
We use Anthromes 2 dataset as an indicator of long-term anthropogenic changes in the the terrestrial biosphere (Ellis et al. 2010). General information about the Anthromes project and datasets is available from the Anthroecology Lab and the dataset can be downloaded from the Dataverse repository (Ellis 2019).
Anthromes 2 was the first historical analysis of global changes in anthromes and biomes before and during the Industrial Revolution, from 1700 to 2000.
We do these steps in R using the dataverse package and custom functions to locate and download the target files.
6.1 Set up
Load libraries
Local path
here::i_am("data-preparation/get-anthromes-data.qmd")
target_dir <- here::here("downloaded-data/anthromes")Wrapper function
Let’s create our own function to read a binary file and save it in the local folder.
dataverse_download <- function(repo, arch, localdir=target_dir) {
if (!dir.exists(localdir))
stop("Carpeta inalcanzable")
destino <- here::here(localdir, arch)
if (file.exists(destino)) {
message("Ya existe un archivo con ese nombre/ubicación")
} else {
as_binary <- get_file_by_name(
filename = arch,
dataset = repo)
writeBin(as_binary, destino)
}
}6.2 Download the data
Download the file
file_name <- "anthromes_2_GeoTIFF.zip"
dataverse_download("10.7910/DVN/6KKAWS", file_name)Ya existe un archivo con ese nombre/ubicación
6.3 Prepare the data
Unzip the file directly from the R session:
unzip(here::here(target_dir, file_name), exdir=target_dir, overwrite=FALSE)Check that the files were created in the target folder:
dir(target_dir)[1] "1700" "1800"
[3] "1900" "2000"
[5] "anthromes_2_GeoTIFF.zip" "anthromes_2_legend.png"
[7] "Readme.txt"
That’s it, these files are now ready for our assessment!