library(ingestr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
library(readr)
library(ggplot2)
The package ingestr makes data collection for geographic locations easy and reproducible. This vignette provides an example for collecting climate and soil information for a set of variables which we typically consider in analyses of environment-vegetation relationships.
This is done here for three example sites from the FLUXNET2015
network. To make this work, we must provide a data frame (here
df_sites
) containing columns
sitename, lon, lat
to the function
ingest()
.
<- siteinfo_fluxnet2015 |>
df_sites slice(1:3) |>
select(sitename, lon, lat)
<- ingest(
df_etopo
df_sites,source = "etopo1",
dir = "~/data/etopo/" # adjust this with your local path
|>
) unnest(cols = data) # to get a flat table
Most can be derived from WorldClim data. The advantage of this is that it’s provided at high resolution (30 sec = 1/120 degrees in longitude and latitude, ~833 m around the Equator).
<- list(varnam = c("tavg", "srad", "vapr", "prec"))
settings_worldclim
<- ingest(
df_worldclim
df_sites,source = "worldclim",
settings = settings_worldclim,
dir = "~/data/worldclim"
)
Vapour pressure (vapr
) has to be converted to vapour
pressure deficit, using temperature for caluclating the saturation
vapour pressure.
To get the mean annual ratio of daily AET/PET, we’d need to run SPLASH. Ideally, we’d run site-level simulations with (WorldClim-) downscaled forcing. Alternatively, we can extract it from a global simulation.
<- get_settings_wise(varnam = c("CNrt"), layer = 1:3)
settings_wise
<- ingest(
df_wise
df_sites,source = "wise",
settings = settings_wise,
dir = "~/data/soil/wise"
)
Can be obtained from HWSD. How to use rhwsd package? Not as documented in ingestr link?
This requires start and end years to be specified. Let’s get data from 1990 to 2009 and then calculate the mean annual total.
<- ingest(
df_ndep |>
df_sites mutate(year_start = 1990, year_end = 2009),
source = "ndep",
timescale = "y",
dir = "~/data/ndep_lamarque/",
verbose = FALSE
|>
) unnest(cols = data) |>
group_by(sitename) |>
summarise(noy = mean(noy), nhx = mean(nhx)) |>
mutate(ndep = noy + nhx) |>
select(-noy, -nhx)