write_raster_factors: create a template as a yaml file for supplying code...

View source: R/write_raster_factors.R

write_raster_factorsR Documentation

create a template as a yaml file for supplying code definition metadata for spatial rasters if raster values are categorical

Description

write_raster_factors creates a template as a yaml file for supplying code definition metadata for spatial rasters if raster values are categorical.

Usage

write_raster_factors(raster_file, raster_entity, value_name, overwrite = FALSE)

Arguments

raster_file

(character) Quoted full path to raster file.

raster_entity

(character) Unquoted name of the raster object in the R environment.

value_name

(character) Quoted name describing the raster value category (category, code, level would be common examples)

overwrite

(logical) Overwrite an existing template if one exists.

Details

Generate a yaml template file that supports the ability to provide a definition for each level or categorical type. The resulting yaml file is written with the name of the raster file + "_factors". The create_spatialRaster function will search for this file when creating a EML spatialRaster entity.

Value

A template for providing code definition metadata as a yaml file with the file name of the raster + "_factors.yaml" (created in the working directory).

Note

write_raster_factors will take as input either an object of class raster that is already in the environment (raster_entity) or will read a raster file (raster_entity) given a path and filename.

Constructing the template can be extremely computationally and time intensive for large rasters.

Examples


## Not run: 

capemlGIS::write_raster_factors(
 raster_entity = denp3p1,
 value_name    = "lulc_codes"
)

capemlGIS::write_raster_factors(
 raster_file = "file-path-to/denp3p1.img",
 value_name  = "weight_class_bins"
)


## End(Not run)


CAPLTER/capemlGIS documentation built on Feb. 18, 2025, 11:58 p.m.