knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

anthromes: Tools for analyzing long-term population and land use in R

Lifecycle: experimental Codecov test coverage R-CMD-check

An R package for analyzing historical land use and population on regional to global scales. It includes functions to download HYDE 3.2 and Anthromes-12k data (from the Anthromes-12k-DGG repository at https://doi.org/10.7910/DVN/E3H3AK), manipulate them as spatio-temporal arrays, apply the anthromes classification, extract raster data using an equal-area discrete global grid system, and generate common summary tables and visualizations.

It is based on (and supersedes) the R research compendium used to generate the analyses and figures for:

Ellis, E.C., N. Gauthier, K. Klein Goldewijk, R. Bliege Bird, N. Boivin, S. Diaz, D. Fuller, J. Gill, J. Kaplan, N. Kingston, H. Locke, C. McMichael, D. Ranco, T. Rick, M.R. Shaw, L. Stephens, J.C. Svenning, J.E.M. Watson, (2021). People have shaped most of terrestrial nature for at least 12,000 years. PNAS. https://doi.org/10.1073/pnas.2023483118

Read below for a quick setup guide or check out the package vignette for more details and example workflows.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("nick-gauthier/anthromes")

Example

library(anthromes)
library(stars)
library(dplyr)
library(ggplot2)

Read in the anthromes data as a stars object. stars is an R package for working with space-time cubes like the HYDE 3.2 data, which are spatial rasters representing multiple time steps. A stars object prints two pieces of information, the attribute data (which is essentially a tibble that can be manipulated via typical tidyverse functions) and dimension information (which records the spatial and temporal dimensions of the object).

hyde_med

You can manipulate these data using standard dplyr functions. For example, you can use filter and mutate to calculate the total used land area (cropland, grazing land, and urban areas) in the year 2000 AD and print a summary.

hyde_med %>%
  filter(time == '2000AD') %>%
  transmute(used = crops + grazing + urban) %>%
  pull(used) %>%
  summary()

You can easily plot these objects in ggplot using geom_stars().

ggplot() +
  geom_stars(data = hyde_med) +
  scale_fill_viridis_c(na.value = NA, name = expression(km^2)) +
  facet_wrap(~time) +
  labs(title = 'HYDE 3.2 cropland', x = 'Latitude', y = 'Longitude') +
  coord_quickmap() +
  theme_bw()

By default, geom_stars() will only plot the first attribute. If you'd like to plot multiple attributes at a time, the easiest way is to convert the attributes to an extra dimension using stars::merge().

ggplot() +
  geom_stars(data = merge(hyde_med[c(1:2,5),,,])) +
  scale_fill_viridis_c(na.value = NA, name = expression(km^2)) +
  facet_grid(attributes~time) +
  labs(title = 'HYDE 3.2 land use', x = 'Latitude', y = 'Longitude') +
  coord_quickmap() +
  theme_bw()

You can easily animate these data using gganimate.

library(gganimate)

ggplot() +
  geom_stars(data = hyde_med) +
  scale_fill_viridis_c(na.value = NA, name = expression(km^2)) +
  # use transition_states() from gganimate instead of facet_wrap to animate
  transition_states(time, transition_length = 0.5) +
  labs(title = 'HYDE 3.2 land use', 
       subtitle = 'Cropland at {closest_state}', 
       x = 'Latitude', y = 'Longitude') +
  coord_quickmap() +
  theme_bw()

Please refer to the excellent stars documentation at https://r-spatial.github.io/stars/ for more information about working with spatio-temporal arrays in R.

Anthromes classification

The main function of the package is anthrome_classify(), which applies the anthromes v2.1 classification algorithm originally presented in :

Ellis, E.C., A.H.W. Beusen, K. Klein Goldewijk, (202). Anthropogenic Biomes: 10,000 BCE to 2015 CE. Land, 9 (5). https://doi.org/10.3390/LAND9050129

And later modified in Ellis et al. 2021 above.

'Anthromes classification flowchart (v2.1) from *Ellis et al. 2020*.'

anthrome_classify() requires the HYDE 3.2 data in a spatio-temporal array, along with a 2-dimensional array of fixed input variables such as land area and potential natural vegetation.

anthromes <- anthrome_classify(hyde_med, inputs_med)

The result is a stars object with the resulting anthromes classification, with the same spatial and temporal dimensions as the original HYDE data.

anthromes

As above, these data can be easily plotted in ggplot using geom_stars. The default anthromes color scheme is provided in the function anthrome_colors() for convenience.

ggplot() +
  geom_stars(data = anthromes) +
  facet_wrap(~time) +
  coord_quickmap() +
  scale_fill_manual(values = anthrome_colors(), drop = TRUE) +
  theme_bw() +
  labs(title = 'Anthromes-12k', x = 'Latitude', y = 'Longitude')

Create nicely formatted summaries of the percent land area in each anthrome using anthrome_summary().

anthrome_summary(anthromes, inputs_med)

How to cite

This package is currently in development, with submission to rOpenSci planned shortly. In the interim, please cite the original R compendium at:

Gauthier, Nicolas (2021). Anthromes 12K DGG (V1) analysis code and R research compendium. Online at Harvard Dataverse, https://doi.org/10.7910/DVN/6FWPZ9



nick-gauthier/anthromes-12k documentation built on June 26, 2022, 3:21 p.m.