Skip to content

transitlos.map.metro_areas

Metropolitan areas on the nation-wide maps: stats chunks (one per area), the stats index entries and the dotted boundary layer.

build_metro_chunks cuts a <key>.json.gz per metropolitan area out of the per-state stats chunks (the cells of its member municipalities / counties, same column layout as a state chunk without the county / place indexes) and appends index["metros"] ({key, name, bbox, pop, n, members}) to stats_chunks/index.json; the scope bar then offers each area as a level of its own. metro_lines_geojson turns the area polygons into boundary lines and metro_lines_script is the map layer: a thick black dotted line with a white halo (readable on any fill), visible from MIN_ZOOM, with its own checkbox in the layer panel.

build_metro_chunks(chunk_dir, areas, members, member_level='place')

Write metro_<code>.json.gz for every area and extend index.json; members is {municipality / county id: area code}.

member_level is the stats-chunk index the ids belong to: "place" (Spain municipalities) or "county" (US counties).

Parameters:

Name Type Description Default
chunk_dir str

Stats chunk folder (with index.json).

required
areas Dict[str, str]

{area code: name}.

required
members Dict[str, str]

{member id: area code}.

required
member_level str

"place" or "county".

'place'

Returns:

Type Description
List[dict]

The area entries added to the index.

metro_lines_geojson(polygons, name_col='name', tolerance_deg=0.0015)

Boundary lines (outer and inner rings) of the area polygons (a GeoDataFrame in EPSG:4326), lightly simplified.

Parameters:

Name Type Description Default
polygons

Area polygons (EPSG:4326).

required
name_col str

Name column.

'name'
tolerance_deg float

Simplification tolerance (degrees).

0.0015

lines_script(geojson_url, label, prefix, min_zoom, width=1.0)

Dotted black boundary layer (white halo) with its own checkbox; prefix keeps several such layers apart (metro, core).

Parameters:

Name Type Description Default
geojson_url str

URL of the lines GeoJSON.

required
label str

Checkbox label.

required
prefix str

Id prefix of the layer.

required
min_zoom float

First zoom shown.

required
width float

Line width.

1.0

metro_lines_script(geojson_url, label='Metro areas')

The metro-area boundary layer (see :func:lines_script).

Parameters:

Name Type Description Default
geojson_url str

URL of the lines GeoJSON.

required
label str

Checkbox label.

'Metro areas'

Returns:

Type Description
str

<script> block.