Draw pretty maps from OpenStreetMap data! Built with osmnx +matplotlib + shapely
Draw pretty maps from OpenStreetMap data! Built with osmnx +matplotlib + shapely
A minimal Python library to draw customized maps from OpenStreetMap created using the osmnx, matplotlib, shapely and vsketch packages.
This work is licensed under a GNU Affero General Public License v3.0 (you can make commercial use, distribute and modify this project, but must disclose the source code with the license and copyright notice)
Install prettymaps with:
pip install prettymapsInstall prettymaps with:
!pip install -e "git+https://github.com/marceloprates/prettymaps#egg=prettymaps"Then restart the runtime (Runtime -> Restart Runtime) before importing prettymaps
After prettymaps is installed, you can run the front-end (streamlit) application from the prettymaps repository using:
streamlit run app.pyThe full tutorial is at docs/tutorial.md — a markdown walkthrough with rendered images, the [Plot] dataclass fields, the layers/style parameters, presets, multiplot, hillshade, and keypoints.
Quick start:
import prettymaps
plot = prettymaps.plot('Stad van de Zon, Heerhugowaard, Netherlands')| Resource | Where to find it |
|---|---|
| Full tutorial (markdown + images) | docs/tutorial.md |
| Interactive marimo notebook (runnable) | notebooks/tutorial.py |
| Open in Google Colab | Open in Colab |
| Streamlit front-end | streamlit run app.py |
# Install marimo (already in requirements.txt)
pip install marimo
# Open the notebook in your browser
marimo edit notebooks/tutorial.pyThe most important prettymaps.plot() parameters are:
layers — dict of OpenStreetMap layers to fetch.style — dict of matplotlib style parameters per layer.preset — load a JSON preset (e.g. 'default', 'minimal', 'macao', 'tijuca').circle / radius / dilate — boundary shape.plot is a dataclass with geodataframes (per-layer GeoDataFrames), fig, and ax.
plot = prettymaps.plot(
'Praça Ferreira do Amaral, Macau',
circle=True,
radius=1100,
layers={
"water": {"tags": {"natural": ["water", "bay"]}},
"building": {"tags": {"building": True}},
},
style={
"water": {"fc": "#a1e3ff", "ec": "#2F3737"},
"building": {"palette": ["#FFC857", "#E9724C", "#C5283D"]},
},
)See docs/tutorial.md for the full set of examples (Macau, Bom Fim, mosaic, Barcelona plotter, Tijuca, multiplot, hillshade, Garopaba keypoints).
Overpass API max retries exceeded
[Bug] KeyError highway crashes plot() when Overpass returns partial/empty data
Bug: fetch.py swallows ALL exceptions silently — impossible to debug OSM fetch failures
Bug: plot() returns Plot dataclass, not (fig, ax) — breaks documented usage pattern
Bug: draw.py hard-imports cv2/vsketch/rasterio at top-level — missing dep = opaque crash
Bug: python_requires>=3.12 contradicts vsketch<3.14 dependency constraint
[Bug] pip install -e . produces __editable__.pth that site.py silently skips
Parts of water not mapped properly
[BUG] Fatal Python error: Segmentation fault
Kernel crashes with larger radius