transitlos.map.popup_cells¶
Res-9 data of the click / address popup (user 2026-11-16: "the stats popups stats resolution should be h3 res 9").
The pages' stats data stay at res 8 (a res-9 copy would be ~7 times larger: tens to hundreds of MB), so the popup reads its own small files, fetched only for the point clicked:
popup9/index.json {"res": 9, "chunk_res": 5, "cols": [...], "scopes": [kind, ...]}
popup9/c/<res-5 parent>.json.gz {"h3": [...], "v": [[value per col], ...], "<kind>": [scope id per cell], ...}
popup9/q/<kind>_<id>.json {col: quantiles} (101 points for the wider scopes, 21 for the many small ones)
write_popup_cells(cells, out_dir, scopes) writes them from one frame of res-9 cells (column h3, the numeric columns of the map and one
id column per scope kind). The browser side is POPUP9_JS (window.__popup9): row lookup, nearest populated neighbour, percentile tables.
write_popup_cells(cells, out_dir, scopes, wide=(), cols=None, chunk_res=CHUNK_RES, extra_quantiles=None)
¶
cells: pandas frame of populated res-9 cells (h3 + numeric columns). scopes: {kind: array of scope ids, one per cell (None = none)}.
wide: the scope kinds with few, large members (state, nation, metro ...) -> 101-point tables; others get 21 points.
extra_quantiles: {name: boolean mask} for whole-frame tables such as the nation (written as q/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
Populated res-9 cells. |
required | |
out_dir
|
str
|
Output folder. |
required |
scopes
|
Dict[str, Iterable]
|
|
required |
wide
|
Iterable[str]
|
Scope kinds with 101-point tables. |
()
|
cols
|
Optional[List[str]]
|
Columns; |
None
|
chunk_res
|
int
|
H3 resolution of the cell chunks. |
CHUNK_RES
|
extra_quantiles
|
Optional[Dict[str, ndarray]]
|
|
None
|
Returns:
| Type | Description |
|---|---|
str
|
The |
world_quantiles(frames, out_path, cols=None)
¶
101-point table over the res-9 cells of several frames (all the cities of the combined map) -> out_path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Iterable
|
Cell tables of the cities. |
required |
out_path
|
str
|
Output JSON. |
required |
cols
|
Optional[List[str]]
|
Columns; |
None
|
Returns:
| Type | Description |
|---|---|
str
|
|
write_popup_source(cells, key, out_dir, county=None)
¶
Per state / community, from the stats-chunk step: <out_dir>/popup_src/<key>.parquet = the populated res-9 cells (h3 + the map's
numeric columns as float32) with u_county (the county / province GeoDataFrame county, GEOID by cell centre) and u_state = key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
Populated res-9 cells. |
required | |
key
|
str
|
State / community key. |
required |
out_dir
|
str
|
Stats chunk folder. |
required |
county
|
County / province polygons (GEOID). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path of the parquet. |
build_popup_from_sources(chunk_dir)
¶
popup9/ of a nation-wide map from every popup_src/<state>.parquet: county and state tables, and the nation's (q/nation.json).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_dir
|
str
|
Stats chunk folder with |
required |
Returns:
| Type | Description |
|---|---|
str
|
The |