View source: R/cartogram_ncont.R
cartogram_ncont | R Documentation |
Construct a non-contiguous area cartogram (Olson 1976).
cartogram_ncont(x, weight, k = 1, inplace = TRUE)
## S3 method for class 'SpatialPolygonsDataFrame'
cartogram_ncont(x, weight, k = 1, inplace = TRUE)
## S3 method for class 'sf'
cartogram_ncont(x, weight, k = 1, inplace = TRUE)
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 |
An object of the same class as x with resized polygon boundaries
Olson, J. M. (1976). Noncontiguous Area Cartograms. In The Professional Geographer, 28(4), 371-380.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.