DoU_plot_grid {flexurba}R Documentation

Plot the grid cell classification

Description

The function can be used to plot the results of the grid cell classification of the Degree of Urbanisation. The implementation relies upon the function tidyterra::geom_spatraster(). 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 grid classification.

Usage

DoU_plot_grid(
  classification,
  extent = NULL,
  level1 = TRUE,
  palette = NULL,
  labels = NULL,
  title = NULL,
  scalebar = FALSE,
  filename = NULL
)

Arguments

classification

SpatRaster / character. A SpatRaster with the grid cell classification or the path to the grid cell classification file

extent

SpatExtent. If not NULL, the grid classification will be cropped to the provided extent before plotting

level1

logical. Whether the grid is classified according to level 1 of the Degree of Urbanisation (TRUE), or level 2 of the Degree of Urbanisation (FALSE).

palette

named vector with the color palette used to plot the grid cell 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.t

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

classification <- DoU_classify_grid(DoU_load_grid_data_belgium())

# plot with standard color scheme
DoU_plot_grid(classification)

# use custom palette and labels
DoU_plot_grid(classification,
  palette = c("3" = "#e16c72", "2" = "#fac66c", "1" = "#97c197", "0" = "#acd3df"),
  labels = c("UC", "UCL", "RUR", "WAT")
)

[Package flexurba version 0.2.2 Index]