Passer au contenu

Unified interface for downloading Land Use/Land Cover (LULC) data from various sources including ESRI Global LULC, Google Dynamic World, ESA WorldCover, or loading local files.

Utilisation

download_lulc_data(
  boundary_layer,
  iso3,
  product = c("esri_10m", "dynamic_world", "esa_worldcover", "local"),
  gee_project = NULL,
  output_dir = here::here(),
  local_file = NULL,
  year = NULL,
  pus = NULL,
  aggregate_to_pus = FALSE,
  wait_time = 5,
  ...
)

Arguments

boundary_layer

An sf object defining the spatial boundary of interest.

iso3

Character. Three-letter ISO country code.

product

Character. LULC product to download: "esri_10m" (default), "dynamic_world", "esa_worldcover", or "local".

gee_project

Character or NULL. Google Earth Engine cloud project ID. Required for GEE-sourced products (esri_10m, dynamic_world, esa_worldcover).

output_dir

Character. Directory for saving output. Defaults to here::here().

local_file

Character or NULL. Path to local GeoTIFF/COG file. Required when product = "local".

year

Numeric or NULL. Specific year to download. If NULL, uses most recent. For Dynamic World, this creates an annual mode composite. Ignored for ESA WorldCover (fixed at 2021).

pus

SpatRaster or NULL. Planning units raster for GEE-side aggregation.

aggregate_to_pus

Logical. If TRUE and pus is provided, aggregate the data to planning unit resolution in GEE before export. Default is FALSE.

wait_time

Numeric. Maximum wait time for GEE exports in minutes. Default is 5.

...

Additional arguments passed to underlying download functions.

Valeur de retour

A SpatRaster object of the LULC data with attribute lulc_product indicating the source, or NULL if download failed.

Exemples

if (FALSE) { # \dontrun{
# Download ESRI LULC (default)
lulc <- download_lulc_data(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  gee_project = "my-project"
)

# Download Dynamic World annual composite
lulc_dw <- download_lulc_data(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  product = "dynamic_world",
  gee_project = "my-project",
  year = 2023
)

# Download ESA WorldCover
lulc_esa <- download_lulc_data(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  product = "esa_worldcover",
  gee_project = "my-project"
)

# Use local file
lulc_local <- download_lulc_data(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  product = "local",
  local_file = "path/to/custom_lulc.tif"
)

# Download with GEE-side aggregation to planning units
lulc_agg <- download_lulc_data(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  product = "esri_10m",
  gee_project = "my-project",
  pus = planning_units,
  aggregate_to_pus = TRUE
)
} # }