Skip to contents

Loads a PRIO-GRID variable from disk and returns it as a terra SpatRaster. By default, loads from the official PRIOGRID release matching the current package version. Can also load custom data generated by the user.

Usage

load_pgvariable(
  varname,
  custom = FALSE,
  version = NULL,
  type = NULL,
  spatial_hash = NULL,
  temporal_hash = NULL
)

Arguments

varname

Character string with the variable name

custom

Logical. If TRUE, loads from custom output directory using current pgoptions settings. Default FALSE.

version

Character string specifying PRIOGRID version (e.g., "3.0.1"). If NULL, uses current package version. Ignored if loading custom data.

type

Character string specifying release type (e.g., "05deg_yearly"). If NULL, uses "05deg_yearly". Ignored if loading custom data.

spatial_hash

Character string with 6-character spatial hash for custom data. Requires temporal_hash. Overrides pgoptions if provided.

temporal_hash

Character string with 6-character temporal hash for custom data. Requires spatial_hash. Overrides pgoptions if provided.

Value

Terra SpatRaster object

Examples

if (FALSE) { # \dontrun{
  # Load from current official release (default)
  r <- load_pgvariable("cshapes_gwcode")

  # Load from specific official release
  r <- load_pgvariable("cshapes_gwcode",
                       version = "3.0.1",
                       type = "05deg_yearly")

  # Load from custom data using current pgoptions
  r <- load_pgvariable("cshapes_gwcode", custom = TRUE)

  # Load from specific custom configuration
  r <- load_pgvariable("cshapes_gwcode",
                       custom = TRUE,
                       spatial_hash = "ecf4dd",
                       temporal_hash = "727cca")
} # }