DoU_plot_units {flexurba} | R Documentation |
Plot the spatial units classification
Description
The function can be used to plot the results of the spatial units classification of the Degree of Urbanisation. The implementation relies upon the function ggplot2::geom_sf()
. By default, the standard color scheme of the Global Human Settlement Layer (GHSL) is used (see GHSL Data Package 2023), but this can be altered by the palette
argument.
Note that the function is computational quite heavy for large spatial extents (regional or global scale). It is advised to use the extent
argument to plot only a selection of the spatial units classification.
Usage
DoU_plot_units(
units,
classification = NULL,
level1 = TRUE,
extent = NULL,
column = NULL,
palette = NULL,
labels = NULL,
title = NULL,
scalebar = FALSE,
filename = NULL
)
Arguments
units |
object of class |
classification |
dataframe with the classification of the spatial units, as returned by |
level1 |
logical. Whether the spatial units are classified according to level 1 of the Degree of Urbanisation ( |
extent |
SpatExtent or an object of class "bbox" ( |
column |
character. Column name of the spatial units classification. By default, |
palette |
named vector with the color palette used to plot the spatial units classification. If |
labels |
vector with the labels used in the legend. If |
title |
character. Title of the plot. |
scalebar |
logical. Whether to add a scale bar to the plot. |
filename |
character. Path to the location to save the plot |
Value
ggplot object
Examples
# get spatial units classification
data_belgium <- DoU_load_grid_data_belgium()
grid_classification <- DoU_classify_grid(data_belgium)
data1 <- DoU_preprocess_units(
units = flexurba::units_belgium,
classification = grid_classification,
pop = data_belgium$pop
)
units_classification <- DoU_classify_units(data1)
# plot using the standard color palette
DoU_plot_units(data1$units, units_classification)
# plot using custom palette and labels
DoU_plot_units(data1$units, units_classification,
palette = c("3" = "#e16c72", "2" = "#fac66c", "1" = "#97c197"),
labels = c("C", "T", "R")
)