basemap
basemap
#
basemap — a muted street map under a chart of places.
- Frame. The chart is framed around the places in Web Mercator metres, stray fixes aside, and widened to a minimum size.
- Tile. OpenStreetMap tiles at the zoom the chart's width needs are
fetched once each (
osm_tileis memoized), stitched and muted under the data. - Project. The returned function places any latitude and longitude on the chart.
LEAST_HALF_METERS = 40.0
module-attribute
#
Half the smallest stretch of ground a basemap shows.
Projection = Callable[[np.ndarray, np.ndarray], tuple[np.ndarray, np.ndarray]]
#
(latitude, longitude) in degrees to (x, y) on the chart.
basemap(axes, locations)
#
Frame axes around locations over a muted OpenStreetMap street map.
to_map = guidance.basemap(figure.axes, photographed)
figure.axes.scatter(*to_map(latitudes, longitudes))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
Axes
|
The chart to draw on; it takes equal aspect and loses its ticks. |
required |
locations
|
Array[Location]
|
The places to frame; the outermost 2% are left out of the frame. |
required |
Returns:
| Type | Description |
|---|---|
Projection
|
The projection from latitude and longitude onto the chart. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
URLError
|
If a tile cannot be fetched. |
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/guidance/basemap.py
mercator(latitude, longitude)
#
Latitude and longitude, in degrees, as Web Mercator metres.
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/guidance/basemap.py
osm_tile(zoom, x, y)
#
One OpenStreetMap tile, fetched once and kept.
Raises:
| Type | Description |
|---|---|
URLError
|
If the tile server cannot be reached or refuses. |