Learn R Programming

flexurba (version 0.2.3)

get_clusters: Identify clusters of cells that meet the criteria

Description

Identify clusters of cells that meet the minimum density criterium/citeria, the minimum size criterium and the contiguity criterium.

The function can be executed with one density criterium, or with two density criteria:

  • With one density criterium: Cells are selected if their value is above or equal to the density threshold (xden >= minden). Selected cells are afterwards grouped together based on the contiguity rule. Groups of cells are valid clusters if they also meet the total size criterium (sum of xsiz per group above or equal tominsiz).

  • With two density criteria: Cells are selected if their value is above or equal to one of two density thresholds (xden >= minden, or xden2 >= minden2). Selected cells are afterwards grouped together based on the contiguity rule. Groups of cells are valid clusters if they also meet the total size criterium (sum of xsiz per group above or equal tominsiz).

Usage

get_clusters(
  xden,
  minden,
  xden2 = NULL,
  minden2 = NULL,
  xsiz = NULL,
  minsiz,
  directions
)

Value

SpatRaster with cluster of cells. The value of the cells represent the id of the clusters.

Arguments

xden

SpatRaster. Grid for density criterium 1

minden

numeric. Minimum density threshold 1

xden2

SpatRaster. Grid for density criterium 2

minden2

numeric. Minimum density threshold 2

xsiz

SpatRaster. Grid for the size criterium. If NULL, then xden is employed for the size criterium.

minsiz

numeric. Minimum size threshold

directions

integer. Which cells are considered adjacent: 4 for rooks case (horizontal and vertical neighbours) or 8 for queens case (horizontal, vertical and diagonal neighbours)

Examples

Run this code
# load data
grid_data_belgium <- flexurba::DoU_load_grid_data_belgium()

# get clusters of cells (4-cell connectivity) with at least 1500 inhabitants
# per km² of permanent land and a minimum total population of 50 000
# inhabitants:
terra::plot(get_clusters(
  xden = grid_data_belgium$pop_per_land,
  minden = 1500,
  xsiz = grid_data_belgium$pop,
  minsiz = 50000,
  directions = 4
))

# get clusters of cells (4-cell connectivity) with at least 1500 inhabitants
# per km² of permanent land or at least 20% built-up area per permanent
# land, and a minimum total population of 50 000 inhabitants:
terra::plot(get_clusters(
  xden = grid_data_belgium$pop_per_land,
  minden = 1500,
  xden2 = grid_data_belgium$built_per_land,
  minden2 = 0.2,
  xsiz = grid_data_belgium$pop,
  minsiz = 50000,
  directions = 4
))

# get clusters of cells (8-cell connectivity) with at least 300 inhabitants
# per km² of permanent land, and a minimum total population of 5000
# inhabitants:
terra::plot(get_clusters(
  xden = grid_data_belgium$pop_per_land,
  minden = 300,
  xsiz = grid_data_belgium$pop,
  minsiz = 5000,
  directions = 8
))

Run the code above in your browser using DataLab