mh_overlay | R Documentation |
Combines multiple single-layer rasters (tif
), outputs from mh_rep
or mh_rep_ch
for different input polygons, into a multi-layered SpatRaster
.
This function handles inputs from both mh_rep
(which primarily contains Represented areas) and mh_rep_ch
(which includes Retained, Lost, and Novel areas). The output layers consistently represent counts of each input.
mh_overlay(folder_path)
folder_path |
|
This function streamlines the aggregation of Climate Representativeness classifications. It is designed to work with outputs from both mh_rep
and mh_rep_ch
.
For each of the three key categories (Lost, Retained/Represented, Novel), the function:
Identifies and reads all .tif
files within the folder_path
.
For each input raster, it creates a binary layer: 1
if the cell's value matches the target category (e.g., 2
for 'Lost'), and 0
otherwise.
Sums these binary layers to generate a cumulative count for that specific category at each grid cell.
The three resulting count layers (Lost, Retained, Novel) are then consistently stacked in the following order:
First layer (Red): Cumulative count of Lost.
Second layer (Green): Cumulative count of Retained.
Third layer (Blue): Cumulative count of Novel.
This fixed order ensures that the output SpatRaster
is immediately ready for direct RGB visualization using terra::plotRGB()
, where the color mixtures will intuitively reflect
the spatial agreement of these change types.
The output SpatRaster
contains raw counts. While terra::plotRGB()
often handles stretching for visualization, users might normalize these counts manually (e.g., to 0-255) for finer control over visual contrast.
A new subfolder named overlay/
will be created within the folder_path
. The resulting three-layered RGB will be saved as ClimaRep_overlay.tif
inside this new overlay/
subfolder.
Writes the multi-layered (ClimaRep_overlay.tif
) outputs to disk in a new overlay
subfolder within the folder_path
.
When mh_rep_ch
results are used, the output layers consistently represent counts for Lost (Red), Retained (Green), and Novel (Blue) categories across all input rasters. Designed for direct RGB plotting.
When mh_rep
results are used, the output layers consistently represent counts for Represented categories across all input rasters.
ClimaRep_overlay <- ClimaRep::mh_overlay(folder_path = system.file("extdata", package = "ClimaRep"))
terra::plotRGB(ClimaRep_overlay)
terra::plot(ClimaRep_overlay)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.