Learn R Programming

clc

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.

Installation

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::pak("josesamos/clc")

Example

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)

source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc")

clc_data <- clc(source = source_gpkg, layer_name = "clc")

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.

region <- sf::st_read(source_gpkg, layer = "lanjaron", quiet = TRUE)

clc_clipped <- clc_data |> 
  cut_to_extent(region)

clc_clipped |> 
  plot_clc()

Convert the clipped CLC data to raster format and visualize it with styles.

raster_path <- system.file("extdata", "mdt.tif", package = "clc")

base_raster <- terra::rast(raster_path)

clc_raster <- clc_clipped |> 
  as_raster(base_raster = base_raster)

clc_raster |> 
  plot_clc()

Save the clipped data and its styles to a new GeoPackage.

output_gpkg <- tempfile(fileext = ".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_r <- clc_raster |>
  get_raster()

output_tif <- tempfile(fileext = ".tif")

terra::writeRaster(clc_r,
                   output_tif,
                   filetype = "GTiff",
                   overwrite = TRUE)

Copy Link

Version

Install

install.packages('clc')

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

December 10th, 2024

Functions in clc (1.0.0)

as_raster

Convert a `clc` Object to Raster Format
clc

`clc` S3 Class
get_raster

Retrieve a Raster Representation of CLC
clc_codes

CLC Codes
get_colors.clc

Retrieve Colors from a CLC Style Definition
plot_clc

Plot CLC Layer
cut_to_extent

Clip the Layer with a Polygon
prepare_plot

Prepare a Plot for CLC Vectorial Data
get_levels.clc

Retrieve Levels from a CLC Style Definition
copy_to

Copy a Style to a GeoPackage or PostGIS Database
safe_clip_multipoligon

Safely Clip a Multipolygon Vector Layer
save_to

Save a Layer and its Style to a GeoPackage or PostGIS Database