TileMapBase is a Python library that enables the use of OpenStreetMap and other WMTS tiles as basemaps within Matplotlib figures. It simplifies fetching, caching, and rendering geographical tiles, allowing users to overlay their data on real-world maps. Currently at version 0.4.7, it is actively maintained with periodic updates.
pip install tilemapbaseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize TileMapBase, define a geographical extent, create a Matplotlib figure and axes, add OpenStreetMap tiles using PlottingContext, and overlay a data point (London Eye) correctly using the `tilemapbase.crs_geographic` transform.
Always call `tilemapbase.init()` at the start of your script and provide a unique `user_agent` string, e.g., `tilemapbase.init(user_agent="my-app-name/1.0")`.
Update your imports: change `from tilemapbase.transform import ...` to `import tilemapbase` and then use `tilemapbase.map_to_pixels(...)` or `tilemapbase.pixels_to_map(...)`.
If your data is in WGS84 (latitude/longitude), use `transform=tilemapbase.crs_geographic` with Matplotlib plotting functions (e.g., `ax.plot(lon, lat, transform=tilemapbase.crs_geographic)`).
TileMapBase uses `cachecontrol` for caching, which helps. Ensure your `user_agent` is identifiable and respect providers' usage policies. For heavy usage, consider self-hosting tiles or using a commercial provider with an API key.