Download LULC Class Proportions from GEE
download_lulc_proportions.RdDownloads 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.
Argumentos
- boundary_layer
An
sfobject 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(seeget_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.
Valor
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.
Detalhes
This function:
Loads the LULC ImageCollection in GEE
For each class, creates a binary mask (class = 1, other = 0)
Exports each class proportion as a separate GeoTIFF
Reprojects locally to PU CRS using bilinear interpolation
The resulting rasters can be used directly in consumer functions:
Use
props$agricultureforagricultural_areas_inputUse
props$built_areaforbuilt_areas_inputValues are already 0-1 proportions, ready for threshold comparison
Exemplos
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,
...
)
} # }