Skip to contents

nycggurban is a ggplot2 extension for thematic maps in the manner of Joseph Passonneau and Richard Saul Wurman’s Urban Atlas: 20 American Cities (MIT Press, 1966). The atlas laid a regular lattice of 250 m cells over each city and printed one graded symbol per cell, in a single spot colour for each variable, at the same scale for every city. This package provides the pieces of that method: the lattice, the symbols, the inks, the legend, and the plate.

The package is for maps of New York City, and uses data packages such as nycmaps and nycdemog in its examples. The geoms, scales, and theme also work with any projected spatial data, and with ordinary charts.

Installation

You can install the development version of nycggurban from GitHub with:

# install.packages("pak")
pak::pak("kjhealy/nycggurban")

The default typeface is Manifold CF. You must install it separately. You can use the Broadway, Subway, or Narroway fonts instead, if you have them. See urban_fonts(). Without these fonts the theme uses the default sans-serif. Draw plots on a graphics device that uses systemfonts, such as those of the ragg package.

Symbols on a lattice

geom_urban_disc() draws a ring in every cell, with a disc that grows with the class of the cell. scale_level_binned() classes a continuous variable, and leaves cells below the first break empty, as the atlas did.

library(ggplot2)
library(nycggurban)

cells <- expand.grid(x = 1:12, y = 1:7)
cells$people <- 4200 * exp(-((cells$x - 4)^2 + (cells$y - 4)^2) / 9)

ggplot(cells, aes(x, y, level = people)) +
  geom_urban_disc() +
  scale_level_binned(
    name = "RESIDENTIAL POPULATION DENSITY",
    breaks = c(50, 200, 500, 1200, 3600)
  ) +
  coord_equal() +
  theme_urban(base_size = 7)

A lattice of ringed disc symbols in brick red. Discs are largest around one point and shrink with distance from it, and cells far from the point are empty. A legend strip above shows five symbols with their ranges.

geom_urban_rings() is the atlas’s personal income symbol, and geom_urban_square() its land-use symbol. Set overprint = TRUE to print one layer over another as a second ink.

A plate of New York

urban_grid() builds the lattice and urban_aggregate() moves polygon data onto it. This example sums the 2020 census block populations from nycdemog onto 250 m cells. It draws them over a base map at the atlas’s scale of 1:48,000.

library(sf)
library(dplyr)

blocks <- nycmaps::nyc_census_blocks_2020_sf |>
  select(geoid) |>
  inner_join(
    nycdemog::nyc_block_20_adults_df |> select(geoid, total_pop),
    by = "geoid"
  ) |>
  filter(total_pop > 0) |>
  st_make_valid()

grid <- urban_grid(blocks)
cells <- urban_aggregate(blocks, grid, "total_pop")
panel <- urban_panel(963000, 172000)

ggplot() +
  layer_urban_base(panel) +
  geom_urban_disc(
    data = st_drop_geometry(cells),
    aes(x, y, level = total_pop),
    pitch = attr(grid, "pitch")
  ) +
  scale_level_binned(
    name = "RESIDENTIAL POPULATION DENSITY",
    breaks = c(50, 200, 500, 1200, 3600)
  ) +
  coord_urban(panel) +
  labs(caption = "NEW YORK WEST · 2020") +
  theme_urban(base_size = 7)

A map of Manhattan, western Brooklyn and Queens, and the south Bronx, covered by a lattice of brick-red disc symbols over a faint tan street map. Solid discs mark the densest cells, on the Upper East Side and Upper West Side; parks, industrial land, and water are empty.

urban_panel_size() gives the size at which to save a panel so that it is at true scale.

Inks

There are three ink palettes. "brick", the default, stays close to the original inks but remains legible under red-green colour-vision deficiency. "atlas" is the ink set of 1966, and "harvest" is an earth-tone alternative.

urban_inks()
#>   density    income     built      open      base     paper 
#> "#B8401F" "#1F6FA8" "#4A3548" "#98CE59" "#C3B0A0" "#FDF5EF"
urban_inks("atlas")
#>   density    income     built      open      base     paper 
#> "#BF2444" "#03538D" "#54366A" "#98CE59" "#C3B0A0" "#FDF5EF"

Charts

The symbols are not limited to maps. On any lattice of values they make a graded alternative to a heat map, and each symbol is the largest that fits its cell.

ggplot(diamonds, aes(cut, clarity)) +
  geom_urban_disc(aes(level = after_stat(n)), stat = "sum") +
  scale_level_binned(
    name = "DIAMONDS",
    breaks = c(1, 500, 1500, 3000, 4500)
  ) +
  theme_urban(base_size = 8, axes = TRUE)

A chart of diamond cut against clarity, with a ringed disc symbol in each cell showing the number of diamonds. The largest discs are for Ideal cut diamonds of clarity VS2 and SI1.