CORINE Land Cover (CLC) is a European land use and land cover classification system that provides standardized geospatial data on land cover categories. It includes an associated style definition, typically stored in formats like GeoPackage, which links land cover codes to descriptive labels and visualization attributes (e.g., colors) for consistent representation across GIS platforms.
The clc
package simplifies workflows for common tasks,
such as reading a CLC vector file, visualizing it with its style,
clipping the data to a region, saving the output with its style, and
converting it to raster format, supporting CLC data in both GeoPackage
and PostGIS as sources and destinations.
You can install the released version of clc
from CRAN with:
install.packages("clc")
And the development version from GitHub with:
# install.packages("pak")
::pak("josesamos/clc") pak
This is a basic example which shows you how to solve a common problem.
Read the CLC data from the GeoPackage and visualize the CLC data with styles.
library(clc)
<- system.file("extdata", "clc.gpkg", package = "clc")
source_gpkg
<- clc(source = source_gpkg, layer_name = "clc")
clc_data
|>
clc_data plot_clc()
Read the clipping layer (region of interest), clip the CLC data to the region of interest and visualize the clipped CLC data with styles.
<- sf::st_read(source_gpkg, layer = "lanjaron", quiet = TRUE)
region
<- clc_data |>
clc_clipped cut_to_extent(region)
|>
clc_clipped plot_clc()
Convert the clipped CLC data to raster format and visualize it with styles.
<- system.file("extdata", "mdt.tif", package = "clc")
raster_path
<- terra::rast(raster_path)
base_raster
<- clc_clipped |>
clc_raster as_raster(base_raster = base_raster)
|>
clc_raster plot_clc()
Save the clipped data and its styles to a new GeoPackage.
<- tempfile(fileext = ".gpkg")
output_gpkg
sink(tempfile())
|>
clc_clipped save_to(output_gpkg)
sink()
Get a raster in terra::SpatRaster
format to store it in
a file, for example.
<- clc_raster |>
clc_r get_raster()
<- tempfile(fileext = ".tif")
output_tif
::writeRaster(clc_r,
terra
output_tif,filetype = "GTiff",
overwrite = TRUE)