nc_cartogram: Calculate Non-Contiguous Cartogram Boundaries

Description Usage Arguments Value References Examples

View source: R/nc_cartogram.R

Description

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

Usage

1
2
3
4
5
6
7
8
nc_cartogram(shp, weight, k = 1, inplace = T)

## S3 method for class 'SpatialPolygonsDataFrame'
nc_cartogram(shp, weight, k = 1,
  inplace = T)

## S3 method for class 'sf'
nc_cartogram(shp, weight, k = 1, inplace = T)

Arguments

shp

SpatialPolygonDataFrame or an sf object

weight

Name of the weighting variable in shp

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

Value

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

References

Olson, J. M. (1976), Noncontiguous Area Cartograms. The Professional Geographer, 28: 371–380. doi:10.1111/j.0033-0124.1976.00371.x

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(maptools)
library(cartogram)
library(rgdal)
data(wrld_simpl)

# Remove uninhabited regions
afr <- spTransform(wrld_simpl[wrld_simpl$REGION==2 & wrld_simpl$POP2005 > 0,],
                   CRS("+init=epsg:3395"))

# Create cartogram
afr_nc <- nc_cartogram(afr, "POP2005")

# Plot
plot(afr)
plot(afr_nc, add = TRUE, col = 'red')

# Same with sf objects
library(sf)

afr_sf = st_as_sf(afr)

afr_sf_nc <- nc_cartogram(afr_sf, "POP2005")

plot(st_geometry(afr_sf))
plot(st_geometry(afr_sf_nc), add = TRUE, col = 'red')

cartogram documentation built on May 22, 2018, 5:04 p.m.