AE 17: Visualizing household income in New York

Application exercise
Modified

March 26, 2026

Packages

library(tidyverse)
library(sf)
library(colorspace)
library(scales)
library(crsuggest)

# set default theme
theme_set(theme_minimal())

# create reusable labels for each plot
map_labels <- labs(
  title = "Median household income in New York in 2024",
  subtitle = "By census tract",
  color = NULL,
  fill = NULL,
  caption = "Source: American Community Survey"
)

Load New York 2024 median household income

We will use two data files for this analysis. The first contains median household incomes for each census tract in New York from 2024. The second contains the boundaries of each county in New York.

# load data
ny_inc <- st_read(dsn = "data/ny-inc.geojson")
Reading layer `ny-inc.geojson' from data source 
  `/Users/bcs88/Projects/info-3312/course-site/ae/data/ny-inc.geojson' 
  using driver `GeoJSON'
Simple feature collection with 5397 features and 4 fields (with 17 geometries empty)
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -79.76215 ymin: 40.4961 xmax: -71.85648 ymax: 45.01585
Geodetic CRS:  NAD83
ny_counties <- st_read(dsn = "data/ny-counties.geojson")
Reading layer `ny-counties.geojson' from data source 
  `/Users/bcs88/Projects/info-3312/course-site/ae/data/ny-counties.geojson' 
  using driver `GeoJSON'
Simple feature collection with 62 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -79.76215 ymin: 40.4961 xmax: -71.85648 ymax: 45.01585
Geodetic CRS:  NAD83
ny_inc
Simple feature collection with 5397 features and 4 fields (with 17 geometries empty)
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -79.76215 ymin: 40.4961 xmax: -71.85648 ymax: 45.01585
Geodetic CRS:  NAD83
First 10 features:
         GEOID                                          NAME medincomeE
1  36015010800    Census Tract 108; Chemung County; New York      55881
2  36015000100      Census Tract 1; Chemung County; New York      43271
3  36051030100 Census Tract 301; Livingston County; New York      78649
4  36055013401  Census Tract 134.01; Monroe County; New York      59034
5  36055002300      Census Tract 23; Monroe County; New York      22010
6  36055014301  Census Tract 143.01; Monroe County; New York      67581
7  36055008500      Census Tract 85; Monroe County; New York      44507
8  36055013604  Census Tract 136.04; Monroe County; New York      61912
9  36055001900      Census Tract 19; Monroe County; New York      43411
10 36055006000      Census Tract 60; Monroe County; New York      53478
   medincomeM                       geometry
1       11963 MULTIPOLYGON (((-76.83044 4...
2        4429 MULTIPOLYGON (((-76.82196 4...
3       13483 MULTIPOLYGON (((-77.93474 4...
4       13000 MULTIPOLYGON (((-77.657 43....
5       12220 MULTIPOLYGON (((-77.64784 4...
6       19903 MULTIPOLYGON (((-77.7016 43...
7       11561 MULTIPOLYGON (((-77.62735 4...
8       32602 MULTIPOLYGON (((-77.69645 4...
9       15481 MULTIPOLYGON (((-77.64533 4...
10      15700 MULTIPOLYGON (((-77.56453 4...
ny_counties
Simple feature collection with 62 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -79.76215 ymin: 40.4961 xmax: -71.85648 ymax: 45.01585
Geodetic CRS:  NAD83
First 10 features:
   GEOID                         NAME medincomeE medincomeM
1  36005       Bronx County, New York      48676        895
2  36119 Westchester County, New York     118976       2567
3  36053     Madison County, New York      75499       3230
4  36029        Erie County, New York      72839       1077
5  36091    Saratoga County, New York     100787       3028
6  36031       Essex County, New York      71661       4292
7  36113      Warren County, New York      78442       3623
8  36017    Chenango County, New York      62948       2655
9  36051  Livingston County, New York      74001       2171
10 36063     Niagara County, New York      69633       2124
                         geometry
1  MULTIPOLYGON (((-73.77242 4...
2  MULTIPOLYGON (((-73.77237 4...
3  MULTIPOLYGON (((-75.99243 4...
4  MULTIPOLYGON (((-79.13689 4...
5  MULTIPOLYGON (((-74.1601 43...
6  MULTIPOLYGON (((-74.33683 4...
7  MULTIPOLYGON (((-74.21462 4...
8  MULTIPOLYGON (((-75.88983 4...
9  MULTIPOLYGON (((-78.06078 4...
10 MULTIPOLYGON (((-79.07537 4...

Part 1

Draw a continuous choropleth of median household income

Your turn: Create a choropleth map of median household income in New York. Use a continuous color gradient to identify each tract’s median household income.

Tip

Use the stored map_labels to set the title, subtitle, and caption for this and the remaining plots.

# add code here

Your turn: Now revise the map to use an optimized color gradient for improved readability.

# add code here

Overlay county borders

Your turn: To provide better context, overlay the NY county borders on the choropleth map.

# add code here

Part 2

Your turn: Continuous color palettes can be hard to distinguish visibly. To improve readability, convert the continuous color palette into a discrete one with 6 levels. Additionally, select an appropriate projection method using {crsuggest}.

# add code here