Skip to contents

The plates of the Urban Atlas share one construction. A lattice of 250 m cells is laid over the city. A quantity is totalled for each cell, and because every cell has the same area, the totals can be read as densities. Each cell then gets one symbol from a short graded series, printed in the ink of that variable. This article builds three plates for New York City in that way.

It uses the nycmaps, nycdemog, and nyclion packages for data, and ggnewscale to give two layers their own classes.

The lattice

The 2020 census counted people by block. urban_grid() covers the blocks with cells, and urban_aggregate() divides each block’s population among the cells it overlaps, in proportion to area.

blocks <- nycmaps::nyc_census_blocks_2020_sf |>
  select(geoid) |>
  inner_join(
    nycdemog::nyc_block_20_adults_df |> select(geoid, total_pop),
    by = "geoid"
  ) |>
  mutate(tract = substr(geoid, 1, 11)) |>
  left_join(
    nycdemog::nyc_tract_acs_income_df |>
      select(tract = geoid, per_capita_income),
    by = "tract"
  ) |>
  mutate(income = total_pop * per_capita_income / 1e6) |>
  filter(total_pop > 0, !is.na(income)) |>
  st_make_valid()

grid <- urban_grid(blocks)
pitch <- attr(grid, "pitch")

cells <- urban_aggregate(blocks, grid, c("total_pop", "income")) |>
  st_drop_geometry()

nrow(cells)
#> [1] 11369
head(cells)
#>   cell        x        y total_pop    income
#> 1    3 914942.4 120160.5  8.130897 0.4298643
#> 2    4 915762.6 120160.5  9.670983 0.5112855
#> 3  191 914122.2 120980.7  4.259783 0.2252062
#> 4  192 914942.4 120980.7 28.598520 1.5119466
#> 5  193 915762.6 120980.7 29.197678 1.5436228
#> 6  194 916582.8 120980.7 98.646172 5.2152258

The pitch is given in metres and converted to the units of the coordinate reference system, here feet. income is an estimate of the aggregate personal income of each cell in millions of dollars: the population of each block multiplied by the per-capita income of its census tract.

The panel

A panel of the atlas is 80 cells square, which is 20 km. urban_panel() makes that extent from its south-west corner and snaps it to the lattice.

panel <- urban_panel(963000, 172000)
urban_panel_size(panel, units = "cm")
#>    width   height 
#> 41.66667 41.66667

urban_panel_size() is the size of the panel at 1:48,000. Pass it, with a margin for the legend and caption, to ggsave() for a plate at true scale. The figures below are reduced to fit the page, so the type is set smaller.

Residential population density

geom_urban_disc() draws the symbols and scale_level_binned() classes the population of each cell. Cells below the first break have no symbol. layer_urban_base() supplies the shoreline and streets in the base-map tan. Its strength argument makes them heavier.

density_scale <- function(...) {
  scale_level_binned(
    name = "RESIDENTIAL POPULATION DENSITY",
    breaks = c(50, 200, 500, 1200, 3600),
    ...
  )
}

ggplot() +
  layer_urban_base(panel) +
  geom_urban_disc(data = cells, aes(x, y, level = total_pop), pitch = pitch) +
  density_scale() +
  coord_urban(panel) +
  labs(caption = "NEW YORK WEST · 2020") +
  theme_urban(base_size = 7)
#> Warning: Can't find the font family "Manifold Extended CF".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.
#> Warning: Can't find the font family "Manifold CF".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.

A map of Manhattan, western Brooklyn and Queens, and the south Bronx with a lattice of brick-red disc symbols over a faint tan street map. Solid discs mark the densest cells, on the Upper East and Upper West Sides.

Aggregate income

geom_urban_rings() is the income symbol, with seven levels. The quantity is the total income of all the residents of a cell, not an average or a median, so the legend says so. A cell can have a high total because its residents are rich or because there are many of them. The ink argument of theme_urban() sets the legend in the ink of the variable.

income_scale <- function(...) {
  scale_level_binned(
    name = "AGGREGATE INCOME · $ MILLIONS",
    breaks = c(1, 5, 15, 30, 60, 120, 250),
    ...
  )
}

ggplot() +
  layer_urban_base(panel) +
  geom_urban_rings(data = cells, aes(x, y, level = income), pitch = pitch) +
  income_scale() +
  coord_urban(panel) +
  labs(caption = "NEW YORK WEST · 2020") +
  theme_urban(base_size = 7, ink = "income")

The same map with blue concentric-ring symbols for aggregate personal income. Solid blue discs cover most of Manhattan below Harlem and parts of brownstone Brooklyn; lighter rings cover the Bronx and outer Brooklyn.

Two inks

The atlas printed income over density with no base map. Two things are needed to do the same. overprint = TRUE prints the second layer as a second ink, so that the inks darken where they overlap. And because a plot has one scale for each aesthetic, ggnewscale::new_scale("level") starts a second level scale for the second layer. guide_urban(ink = ) sets each legend in its own ink.

ggplot() +
  geom_urban_disc(data = cells, aes(x, y, level = total_pop), pitch = pitch) +
  density_scale(guide = guide_urban(ink = "density", order = 1)) +
  ggnewscale::new_scale("level") +
  geom_urban_rings(
    data = cells,
    aes(x, y, level = income),
    pitch = pitch,
    overprint = TRUE
  ) +
  income_scale(guide = guide_urban(ink = "income", order = 2)) +
  coord_urban(panel) +
  labs(caption = "NEW YORK WEST · 2020") +
  theme_urban(base_size = 7) +
  theme(legend.box = "vertical", legend.box.just = "left")

The same area with blue income rings printed over brick-red density discs and no base map. Cells that are both dense and rich are dark purple; dense cells with lower incomes show more red.

Other inks and type

urban_inks() has three palettes. The symbol geoms use the "brick" inks by default. Give a layer another ink with colour. theme_urban() takes the same palette argument for the paper and base-map tan, and a fonts argument for the typeface.

ggplot() +
  layer_urban_base(panel, strength = 2) +
  geom_urban_disc(
    data = cells,
    aes(x, y, level = total_pop),
    pitch = pitch,
    colour = urban_inks("atlas")[["density"]]
  ) +
  density_scale() +
  coord_urban(panel) +
  labs(caption = "NEW YORK WEST · 2020") +
  theme_urban(
    base_size = 7,
    fonts = "broadway",
    ink = urban_inks("atlas")[["density"]]
  )
#> Warning: Can't find the font family "Broadway".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.
#> Warning: Can't find the font family "Subway".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.

The population density map again, in the crimson of the original 1966 atlas and with its legend set in the Broadway typeface.