as_raster {clc} | R Documentation |
Convert a 'clc' Object to Raster Format
Description
Returns an object of class 'clc_raster' that contains a 'terra::SpatRaster' raster object representing the converted vector layer into raster format.
Usage
as_raster(clo, base_raster, resolution)
## S3 method for class 'clc'
as_raster(clo, base_raster = NULL, resolution = NULL)
Arguments
clo |
A 'clc' object. |
base_raster |
(Optional) A raster object to use as the base for rasterization. |
resolution |
(Optional) Numeric resolution to define the raster grid. |
Details
The function requires either 'base_raster' or 'resolution' to be provided. If both are missing, an error is raised.
Value
An object of class 'clc_raster'.
See Also
Other CLC class functions:
clc()
,
copy_to()
,
cut_to_extent()
,
get_colors.clc()
,
get_levels.clc()
,
get_raster()
,
plot_clc()
,
prepare_plot()
,
save_to()
Examples
source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc")
clo <- clc(source = source_gpkg, layer_name = "clc")
raster_path <- system.file("extdata", "mdt.tif", package = "clc")
base_raster <- terra::rast(raster_path)
# ex1
r <- clo |>
as_raster(base_raster = base_raster)
# ex2
r <- clo |>
as_raster(resolution = 50)
[Package clc version 1.0.0 Index]