prepare_plot | R Documentation |
Generates a 'ggplot2' object to visualize CLC Vectorial data. The function processes the data stored in a 'clc' object, ensuring that the codes field is mapped correctly to the categories and their associated styles.
prepare_plot(clo)
## S3 method for class 'clc'
prepare_plot(clo)
clo |
A 'clc' object. |
A 'ggplot2' object ready for rendering.
plot_clc
Other CLC class functions:
as_raster()
,
clc()
,
copy_to()
,
cut_to_extent()
,
get_colors.clc()
,
get_levels.clc()
,
get_raster()
,
plot_clc()
,
save_to()
source_gpkg <- system.file("extdata", "clc.gpkg", package = "clc")
clo <- clc(source = source_gpkg, layer_name = "clc")
p <- clo |>
prepare_plot()
levels <- clo |>
get_levels()
p <- p +
ggplot2::scale_fill_manual(
values = stats::setNames(levels$color, levels$id),
labels = stats::setNames(levels$description, levels$id),
name = ""
) +
ggplot2::theme(
legend.position = "right",
legend.key.height = ggplot2::unit(2, "cm"),
legend.title = ggplot2::element_text(size = 12),
legend.text = ggplot2::element_text(size = 10)
) +
ggplot2::theme_minimal()
temp_file <- tempfile(fileext = ".png")
png(filename = temp_file, width = 800, height = 600)
p
dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.