Open-source library turns any area on the map into a poster
Developer Marcelo Prates has released prettymaps, an open-source library that turns any patch of map into a styled poster. Just type in a place name or coordinates, and the code pulls geometry from OpenStreetMap and renders roads, buildings, parks, and bodies of water in whatever color scheme you pick.
The library runs on Python and builds on osmnx, matplotlib, and shapely. Installation takes one command, pip install prettymaps, and it requires Python 3.12 at minimum. If you'd rather skip the code entirely, the repository also includes a Streamlit frontend you can launch with streamlit run app.py.
The rendering process revolves around two dictionaries. The layers parameter defines which OpenStreetMap layers to pull, like buildings tagged as "building" or water tagged as "natural." The style parameter then sets fill color, outline, and matplotlib color palette for each layer.
What's new in version 1.4:
automatic rendering of sea geometry
support for terrain hillshading
ability to add key points to the map
optimizations that cut down on Overpass API requests
ready-made presets, including default, minimal, macao, and tijuca
You can customize the shape of the mapped area too, fitting it into a circle or rectangle. The multiplot function, paired with the Subplot class, lets you combine several districts on a single canvas. The output comes back as a dataclass containing geodataframes for each layer, plus the fig and ax objects from matplotlib, which you can use to add labels or change the background.
Commercial use is allowed as long as you keep the source code open and preserve the copyright notice. Prates also asks that people not strip out the caption crediting the repository and OpenStreetMap, something the mapping service's license actually requires.
One specific rule in the license bans using the library to sell NFTs. Prates calls NFTs a money laundering scheme that hurts the environment, pointing to two teams, AeternaCivitas and geoartnft, that sold work made with his code and refused to credit the source.