raceland: Describing local racial patterns of racial landscapes at different spatial scales

Anna Dmowska, Tomasz Stepinski, Jakub Nowosad



The raceland package implements a computational framework for a pattern-based, zoneless analysis and visualization of (ethno)racial topography. It is a reimagined approach for analyzing residential segregation and racial diversity based on the concept of ‘landscape’ used in the domain of landscape ecology. An overview of the implemented method is presented in the first vignette. Here we demonstrate, how the raceland package can be used for describing racial landscape at different spatial scales.

Racial landscape method is based on the raster gridded data, and unlike the previous methods, does not depend on the division for specific zones (census tract, census block, etc.). Calculation of racial diversity (entropy) and racial segregation (mutual information) can be performed for the whole area of interests (i.e., metropolitan area) without introducing any arbitrary divisions. Racial landscape method also allows for performing the calculation at different spatial scales.

# install required packages 
pkgs = c(
to_install = !pkgs %in% installed.packages()
if(any(to_install)) {

A computational framework requires a few steps (see the first vignette for details) before calculating IT-metrics:

# reading input data
list_raster = list.files(system.file("rast_data", package = "raceland"),
                         full.names = TRUE)
race_raster = stack(list_raster)

# constructing racial landscape
real_raster = create_realizations(x = race_raster, n = 100)

# calculating local subpopulation densities
dens_raster = create_densities(real_raster, race_raster, window_size = 10)


Defining local patterns

Let consider an example presented below. The racial landscape covers the area of 16 by 16 cells. Such an area can be divided into a square-shaped block of cells. Each square of cells will represent a local pattern (a local landscape), and for each local pattern, IT metrics (entropy and mutual information) are calculated. The extent of a local pattern is defined by two parameters: size and shift.

The example presented below consists of the racial landscape 16 by 16 cells. Setting size = 4 (and shift= 4) results in dividing the racial landscape into four squared windows, each 4x4 cells. Each window represents a local pattern. For each local pattern, IT metrics can be calculated, and the results will be assigned to the resultant grid of square windows. In fact, the original racial landscape with 16x16 cells is reduced to the 2x2 ‘large cells’.

Setting size=4 and shift = 2 results in overlapping square windows. First, the window of the size 4x4 defines the local pattern (see dark blue square). In the next step, this window is shifted by two cells to the right, and the new local pattern is selected (see the light blue square). It will create a resultant grid of the cell size defined by the shift parameter.

Calculate IT metrics from local patterns (1)

The create_grid() function creates spatial object with a grid (each ‘cell’ is defined by size and shift). This function requires the RasterStack object with realizations (racial landscapes) and size parameter. If the shift parameter is not set, it is assumed that size=shift. Below such grid is imposed into the racial landscape to show local patterns.

The calculate_metrics() function is used to calculate IT metrics. Parameter size=20 means that the area of interests will be divided into a grid of local patterns of the size 20x20 cells (which in this case corresponds to the square of 0.6 km x 0.6km). The neighboorhood = 4 defines that adjacencies between cells are defined in four directions, fun="mean" calculate average values of population density from adjacent cells, threshold = 0.5 - calculation will be performed if there is at least 50% of non-NA cells.

IT metrics are calculated for each local pattern for each realization. The output table will have 900 rows (there are nine local patterns of size 20x20 cells and 100 realizations).

Racial topography at the analyzed scale is quantified as an ensemble average from multiple realizations. First, for each square window is calculated the average value of entropy and mutual information based on 100 realizations. The table below shows the mean (ent_mean, mutinf_mean) and standard deviation (ent_sd, mutinf_sd) values for each square window.

Then the averages from the mean values of entropy and mutual information are calculated.

Racial diversity-segregation classification

Racial diversity and segregation can be analyzed and displayed separately. However, much more information can be gained by visualizing those two measures at the same time. For this purpose, entropy and mutual information are reclassified into three classes (1-low, 2-medium, 3-high). By joining those two classification, we obtain 9 classes, each describing the level of diversity and segregation: 11 - low segregation/low diversity; 12-low segregation/medium diversity; 13-low segregation/high diversity; 21 - medium segregation/low diversity; 22-medium segregation/medium diversity; 23-medium segregation/high diversity; 31 - high segregation/low diversity; 32-high segregation/medium diversity; 33-high segregation/high diversity.

Each class is coded by one color using bivariate palette (see below).

The bivariate_classification() function presented below takes three arguments (entropy - a vector of entropy values, mutual_information - a vector of mutual information values, n - a number of categories in racial landscape) and return a 9-coded vector of racial segregation/divesity classes.

Mapping local racial diversity and racial segregation

The average value of entropy and mutual information calculated for each square-shaped window from all realizations can be joined to the spatial grid object. Such operation allows for mapping metrics and shows how segregation and racial diversity change over the area.

Mapping local racial diversity and racial segregation

The average value of entropy and mutual information calculated for each square-shaped window from all realizations can be joined to spatial grid object (created by create_grid()). For overlapping windows, the resolution of the grid will be defined by shift parameter.