View source: R/1_2_mask_to_mosaic.R
mask_to_mosaic | R Documentation |
This function applies a binary raster mask to a 2-band burned area mosaic (RBR and DOY). All pixels in the mosaic where the mask does not match 'valid_mask_value' are assigned 'NA'. Optionally, a shapefile can be provided to crop and mask the mosaic to a specific geographic area (e.g., the Iberian Peninsula).
The function ensures that the mask raster is projected and aligned to the mosaic before applying. The output is saved with the same resolution as the input mosaic.
mask_to_mosaic(
mosaic_path,
mask_raster_path,
output_path = NULL,
valid_mask_value = 1,
crs_target = 3035,
shapefile_clip = NULL
)
mosaic_path |
Character. Path to the input 2-band raster mosaic (e.g., with RBR and DOY). |
mask_raster_path |
Character. Path to the binary mask raster (e.g., burnable areas). |
output_path |
Character (optional). Output destination. There are three behaviors:
|
valid_mask_value |
Numeric. Value in the mask that defines valid pixels (default is 1). |
crs_target |
Integer or character. EPSG code for reprojection (only used if needed). Default: 3035. |
shapefile_clip |
Character (optional). Path to a shapefile to further crop and mask the mosaic. |
This function is typically used after mosaicking burned area products derived from satellite imagery. It filters areas outside a burnable mask (e.g., based on land cover) and optionally restricts output to a defined geographic region (e.g., the Iberian Peninsula).
Input mosaic must have: - Band 1: Relative Burn Ratio (RBR) - Band 2: Day of Year (DOY)
Output raster is written in GeoTIFF format with LZW compression.
Character. Full path to the final masked (and optionally clipped) raster.
Examples require large external raster files (hosted on Zenodo). Therefore, they are wrapped in dontrun to avoid errors during R CMD check and to ensure portability.
## Not run:
# Case 1: Let the function generate the output name in the same folder
mask_to_mosaic(
mosaic_path = "data/IBERIAN_MinMin_all_year_2012_mosaic_res90m.tif",
mask_raster_path = "data/burneable_mask_corine_ETRS89.tif"
)
# Case 2: Save the output to a specific folder, name generated automatically
mask_to_mosaic(
mosaic_path = "data/IBERIAN_MinMin_all_year_2012_mosaic_res90m.tif",
mask_raster_path = "data/burneable_mask_corine_ETRS89.tif",
output_path = "outputs/"
)
# Case 3: Define the full output file name explicitly
mask_to_mosaic(
mosaic_path = "data/IBERIAN_MinMin_all_year_2012_mosaic_res90m.tif",
mask_raster_path = "data/burneable_mask_corine_ETRS89.tif",
output_path = "outputs/custom_masked_output_2012.tif"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.