Learn R Programming

cartogram (version 0.3.0)

cartogram_ncont: Calculate Non-Contiguous Cartogram Boundaries

Description

Construct a non-contiguous area cartogram (Olson 1976).

Usage

cartogram_ncont(x, weight, k = 1, inplace = TRUE)

# S3 method for SpatialPolygonsDataFrame cartogram_ncont(x, weight, k = 1, inplace = TRUE)

# S3 method for sf cartogram_ncont(x, weight, k = 1, inplace = TRUE)

Value

An object of the same class as x with resized polygon boundaries

Arguments

x

a polygon or multiplogyon sf object

weight

Name of the weighting variable in x

k

Factor expansion for the unit with the greater value

inplace

If TRUE, each polygon is modified in its original place, if FALSE multi-polygons are centered on their initial centroid

References

Olson, J. M. (1976). Noncontiguous Area Cartograms. In The Professional Geographer, 28(4), 371-380.

Examples

Run this code
library(sf)
library(cartogram)

nc = st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)

# transform to NAD83 / UTM zone 16N
nc_utm <- st_transform(nc, 26916)

# Create cartogram
nc_utm_carto <- cartogram_ncont(nc_utm, weight = "BIR74")

# Plot 
par(mfrow=c(2,1))
plot(nc[,"BIR74"], main="original", key.pos = NULL, reset = FALSE)
plot(st_geometry(nc_utm), main="distorted", reset = FALSE)
plot(nc_utm_carto[,"BIR74"], add =TRUE)

Run the code above in your browser using DataLab