knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(lfcdata) library(dplyr)
CatDrought database offers access to drought stress, soil water content and other modeled variables for Catalunya, powered by the medfate R package.
catdroughtdb <- catdrought() catdroughtdb
CatDrought offers precalculated data at 1km resolution as rasters. This spatial
data can be accesed with the catdrought_get_raster
function:
This function allows to access the raster for a specified date (as character),
and returns a spatial object, whose class depends on the spatial argument.
Available classes are raster
(a RasterBrick object) and stars
(a stars object).
catdrought_get_raster( catdroughtdb, date = as.character(Sys.Date() - 1), spatial = 'stars' )
catdrought_get_raster( catdroughtdb, date = as.character(Sys.Date() - 1), spatial = 'raster' )
date
: a character indicating the date to extractspatial
: a character indicating the output class (raster
or stars
)Only a natural year (365 days from the day before current date) are available
catdrought_get_raster( catdroughtdb, date = as.character(Sys.Date() - 365), spatial = 'stars' )
Instead of rasters, we can obtain a table with the time series for a specified
variable. This time series covers all the available dates. For this, we can
use the catdrought_get_current_time_series
function.
This will extract the values for the desired variable on all the dates available, for the set of points provided:
# points spatial object, obtained from fes database points_sf <- lfcdata::fes()$get_data('plot_nfi_4_results', spatial = TRUE) |> slice(1:5) catdrought_get_current_time_series( catdroughtdb, sf = points_sf, variable = 'Eplant' )
NOTE: This can take some time depending on the number of features.
sf
object with the POINT featuresvariable
the desired variableThe output is a tibble with the following variables:
The process is exactly the same as for points:
# points spatial object, obtained from fes database polygons_sf <- lfcdata::lidar()$get_data('lidar_municipalities', 'AB') |> slice(1:5) catdrought_get_current_time_series( catdroughtdb, sf = polygons_sf, variable = 'Eplant' )
Here, the mean value for the variable and the 0.1 and 0.9 quantiles are returned for all polygons and dates.
NOTE: This can take some time depending on the number of features.
sf
object with the POLYGON or MULTIPOLYGON featuresvariable
the desired variableThe output is a tibble with the following variables:
Information about Variables available can be accessed with
catdroght_describe_var()
function:
catdrought_describe_var(catdroughtdb, c('REW', 'DDS'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.