METHOD LAB 02 · R / SHINY / SF

NHGIS
MAP LAB

Check that an NHGIS extract has the pieces the map needs, then open the supplied R/Shiny application to join attributes and render a choropleth.

01 / ASSEMBLE THE EXTRACT

Choose the whole shapefile bundle.

  • Geometry .shpMISSING
  • Attributes .dbfMISSING
  • Shape index .shxMISSING
  • Projection .prj (recommended)MISSING
  • NHGIS table .csvMISSING

02 / JOIN & MAP

A map with guardrails.

The R/Shiny starter reads the shapefile with sf, reads the NHGIS table with readr, lets you select both join keys and a numeric variable, checks unmatched records, and draws an interactive map with leaflet.

shape <- sf::st_read(shp_path, quiet = TRUE)
nhgis <- readr::read_csv(csv_path, show_col_types = FALSE)

mapped <- dplyr::left_join(
  shape, nhgis,
  by = setNames(input$table_key, input$shape_key)
)

FILES ARE CHECKED LOCALLY AND NEVER UPLOADED