Map Lab
Stores within a radius
Click anywhere in six metro areas to count dollar stores and supermarkets within 1 to 10 miles, from precomputed H3 hexagon counts, checked against the store points.
How many stores are within reach of a point?
This is the fallback version. The guide's plan was for the reader's browser to run ST_DWithin over the metro's store file in DuckDB-WASM. No DuckDB 2.0 WebAssembly build has been published, so nothing on this page runs DuckDB. The pipeline counted the stores in each H3 hexagon at build time, and the page adds those counts up in JavaScript. The panel shows the SQL it would have run.
A resolution-8 hexagon covers about 0.737 km². Chicago's 1,475 stores fall in 1,192 cells. A store inside the circle is missed when its hexagon's centre falls outside, and a store outside is counted when its hexagon's centre falls inside, so the two columns can differ by a store or two. The pipeline ran the exact query at one point per metro, 2 miles from the centre of the densest tract. In Chicago it found 7 supermarkets and 6 dollar stores, and the hexagon sum agreed. In Atlanta the sum found 1 dollar store where the exact query found 2. The table on How these maps were built has all six.
Store counts per H3 cellchapters/07-store-access/pipeline/90_export.sqlShow SQL
CREATE OR REPLACE TABLE metro_hex_r8 AS
SELECT slug, h3_latlng_to_cell(lat, lon, 8) AS cell,
count(*) FILTER (WHERE kind = 'dollar') AS dollar,
count(*) FILTER (WHERE kind = 'supermarket') AS supermarket,
count(*) FILTER (WHERE chain = 'Dollar General') AS dollar_general,
count(*) FILTER (WHERE chain = 'Dollar Tree') AS dollar_tree,
count(*) FILTER (WHERE chain = 'Family Dollar') AS family_dollar
FROM metro_stores GROUP BY ALL;5,585 cells across six metrosRuns at build time in DuckDB 2.0; shown for reading.Open file
h3_latlng_to_cell assigns each store to a hexagon, so a GROUP BY gives counts that can be summed later without the points. Each cell's outline comes from h3_cell_to_boundary_wkt, so the browser can draw hexagons without an H3 library.