Map Lab

Store access by census tract

Six metro areas, each tract coloured by how far its nearest dollar store is compared with its nearest supermarket, with every store plotted, chain toggles, an income filter and a click-through panel.

Which store is closer, tract by tract

Stores shown
0.25×0.50×0.80×1.25×2.00×4.00×
Dollar store closerSupermarket closer
No reliable estimate
Median household income of tract (drag to filter the map)
$0$125k$250k+

0 tracts have an income estimate.

Each census tract is coloured by the distance from its point to the nearest dollar store, divided by the distance to the nearest supermarket. Red means the dollar store is closer and blue means the supermarket is. Dots are stores, coloured by chain or group. Drag across the income histogram to keep only tracts in that range. Click a tract for its numbers.SourceOverture places 2026-10-21.0; TIGER/Line 2024 tracts and CBSAs; ACS 2020-2024 5-year. From Chapter 7.

The six metros hold 8,644 tracts and 6,793 stores, the same counts as Chapter 7's metro index. The store list covers each metro's bounding box plus 0.3 degrees (about 25 to 33 km), so a tract on the edge can show a nearest store that lies outside the metro. Detroit has 739 dollar stores against 279 supermarkets, and Seattle 98 against 300. The two metros sit at opposite ends of Chapter 7's comparison.

Switching a chain off hides its dots but does not change the colours. The tract ratio was computed once, against every chain on Chapter 7's list. Recomputing it for another set of chains means another nearest-neighbour join, which needs DuckDB rather than the browser. Distances are straight lines on the WGS84 spheroid, from the tract's point to the store, and are not travel distances. Tract outlines are simplified one polygon at a time to about 50 m. That keeps every polygon valid but can leave hairline gaps between neighbouring tracts, which the Chapter 7 page avoids by simplifying them together.

One GeoJSON file per metro and layermaplab/pipeline/90_export.sqlShow SQL
90_export.sqlSQL
-- Snap to 5 decimals (about 1 m); the GeoJSON writer has no precision option.
CREATE OR REPLACE MACRO m_stores(s) AS TABLE
SELECT id, chain, kind, ST_ReducePrecision(geom, 1e-5) AS geom FROM stores WHERE slug = s ORDER BY id;

-- ID_COLUMN '' keeps id in the feature's properties, where the map reads it.
COPY (FROM m_stores('detroit')) TO 'public/data/maplab/detroit/stores.geojson'
  (FORMAT GEOJSON, ID_COLUMN '');

6 metros x 3 layers; 4 decimals for tracts and hexagons, 5 for storesRuns at build time in DuckDB 2.0; shown for reading.Open file

COPY ... (FORMAT GEOJSON) is DuckDB 2.0's own GeoJSON writer. Snapping coordinates with ST_ReducePrecision is what keeps the files small: five decimals is about a metre, and four is about ten. The files are 13% smaller than the ones GDAL's GeoJSON driver wrote from the same tables. Store names from Overture are left out, because a free-text name field can hold a person's name, and the chain is enough for the map.

From Chapter 7: Where the dollar store is closer than the supermarket.