as_raster | R Documentation |
Returns an object of class 'clc_raster' that contains a 'terra::SpatRaster' raster object representing the converted vector layer into raster format.
as_raster(clo, base_raster, resolution)
## S3 method for class 'clc'
as_raster(clo, base_raster = NULL, resolution = NULL)
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. |
The function requires either 'base_raster' or 'resolution' to be provided. If both are missing, an error is raised.
An object of class 'clc_raster'.
Other CLC class functions:
clc()
,
copy_to()
,
cut_to_extent()
,
get_colors.clc()
,
get_levels.clc()
,
get_raster()
,
plot_clc()
,
prepare_plot()
,
save_to()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.