catdrought_get_raster: Access to the rasters in the Catdrought database

View source: R/lfcCatDrought.R

catdrought_get_rasterR Documentation

Access to the rasters in the Catdrought database

Description

catdrought_get_raster is a wrapper for the $get_raster method of lfcCatDrought objects. See also catdrought.

Usage

catdrought_get_raster(
  object,
  date,
  spatial = "stars",
  rast_column = "rast",
  bands = TRUE,
  clip = NULL
)

Arguments

object

lfcCatDrought object, as created by catdrought

date

character with the date of the raster to retrieve, i.e "2020-04-25"

spatial

character vector of length 1 indicating the type of raster object to return, "raster" or "stars", the default.

Details

Connection to database can be slow. Rasters retrieved from the db are stored in a temporary cache inside the lfcCatDrought object created by catdrought, making subsequent calls to the same table are faster. But, be warned that in-memory rasters can use a lot of memory!

Value

A raster object: RasterBrick if spatial is raster, stars if spatial is stars. See https://r-spatial.github.io/stars/index.html for details about stars objects and raster for details about raster objects.

See Also

Other catdrought functions: catdrought_describe_var(), catdrought_get_current_time_series(), catdrought()

Examples

if (interactive()) {
  catdroughtdb <- catdrought()
  # raster
  catdrougth_20200425_smoothed <-
    catdrought_get_raster(catdroughtdb, '2020-04-25', 'smoothed', 'raster')
  # stars
  catdrougth_20200425_smoothed_stars <-
    catdrought_get_raster(catdroughtdb, '2020-04-25', 'smoothed', 'stars')

  # we can use pipes
  catdroughtdb |>
    catdrought_get_raster('2020-04-25', 'smoothed', 'raster')

  # catdroughtdb is an R6 object, so the previous examples are the same as:
  catdroughtdb$get_raster('2020-04-25', 'smoothed', 'raster')
  catdroughtdb$get_raster('2020-04-25', 'smoothed', 'stars')
}


MalditoBarbudo/lfcdata documentation built on May 2, 2023, 10:30 p.m.