Skip to contents

Downloads individual proportion rasters from Google Earth Engine where each raster represents the proportion (0-1) of a specific LULC class within each planning unit cell. This is more efficient than downloading categorical LULC and computing proportions locally, as aggregation happens in GEE.

Usage

download_lulc_proportions(
  boundary_layer,
  iso3,
  gee_project,
  output_dir = here::here(),
  lulc_product = c("esri_10m", "dynamic_world", "esa_worldcover"),
  class_names = c("agriculture", "built_area"),
  year = NULL,
  pus,
  wait_time = 30,
  force_download = FALSE
)

Arguments

boundary_layer

An sf object defining the spatial boundary of interest.

iso3

Character. Three-letter ISO country code for filename generation.

gee_project

Character. Google Earth Engine cloud project ID. This is required and must be a valid GEE project you have access to. Find your project ID in the GEE Code Editor.

output_dir

Character. Path to directory for saving the final raster file. Defaults to project root via here::here().

lulc_product

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

class_names

Character vector. Names of classes to extract proportions for. Default is c("agriculture", "built_area"). Must be valid class names for the chosen lulc_product (see get_lulc_classes()).

year

Numeric or NULL. Year for LULC data. If NULL, uses most recent.

pus

SpatRaster. Planning units raster (required for resolution).

wait_time

Numeric. Maximum time in minutes to wait for the GEE export to appear in Google Drive. Default is 5. Increase for large exports.

force_download

Logical. If TRUE, skip local and Drive cache checks and force a new export from GEE. Default is FALSE.

Value

A named list of SpatRaster objects, one per class. Each raster contains proportion values (0-1) at PU resolution. Files are also saved to output_dir with names like {product}_proportion_{year}_{iso3}_{class}.tif.

Details

This function:

  1. Loads the LULC ImageCollection in GEE

  2. For each class, creates a binary mask (class = 1, other = 0)

  3. Exports each class proportion as a separate GeoTIFF

  4. Reprojects locally to PU CRS using bilinear interpolation

The resulting rasters can be used directly in consumer functions:

  • Use props$agriculture for agricultural_areas_input

  • Use props$built_area for built_areas_input

  • Values are already 0-1 proportions, ready for threshold comparison

Examples

if (FALSE) { # \dontrun{
# Download agriculture and built_area proportions
props <- download_lulc_proportions(
  boundary_layer = ghana_boundary,
  iso3 = "GHA",
  gee_project = "my-project",
  lulc_product = "esri_10m",
  class_names = c("agriculture", "built_area"),
  pus = planning_units
)

# Use directly in make_protect_zone
protect <- make_protect_zone(
  iso3 = "GHA",
  pus = planning_units,
  agricultural_areas_input = props$agriculture,
  built_areas_input = props$built_area,
  ...
)
} # }