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 sf. The spatial units to be displayed on the plot

classification

dataframe with the classification of the spatial units, as returned by DoU_classify_units(). If NULL, it is assumed that the classification results are merged in the units object.

level1

logical. Whether the spatial units are classified according to level 1 of the Degree of Urbanisation (TRUE), or level 2 of the Degree of Urbanisation (FALSE).

extent

SpatExtent or an object of class "bbox" (sf). If not NULL, the spatial units will be filtered based on the provided extent before plotting.

column

character. Column name of the spatial units classification. By default, "flexurba_L1" when level1=TRUE and "flexurba_L2" when level1=FALSE.

palette

named vector with the color palette used to plot the spatial units classification. If NULL, the standard color palette of the GHSL is used (see GHSL_palette()).

labels

vector with the labels used in the legend. If NULL, the standard labels of the GHSL are used (see GHSL_labels()).

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")
)

[Package flexurba version 0.2.2 Index]