prettymaps README

The project's README from github.com/marceloprates/prettymaps. As one markdown file: README.md.

prettymaps

A minimal Python library to draw customized maps from OpenStreetMap created using the osmnx, matplotlib, shapely and vsketch packages.

Docs PyPI Python License

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)

Note about crediting and NFTs:

Buy Me a Coffee at ko-fi.com

As seen on Hacker News:

prettymaps subreddit

Tutorial (marimo) · Google Colaboratory Demo

Installation

Install locally:

Install prettymaps with:

pip install prettymaps

Install on Google Colaboratory:

Install prettymaps with:

!pip install -e "git+https://github.com/marceloprates/prettymaps#egg=prettymaps"

Then restart the runtime (Runtime -> Restart Runtime) before importing prettymaps

Run front-end

After prettymaps is installed, you can run the front-end (streamlit) application from the prettymaps repository using:

streamlit run app.py

Tutorial

The 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.

Heerhugowaard sample

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

Run the tutorial locally (marimo)

# Install marimo (already in requirements.txt)
pip install marimo

# Open the notebook in your browser
marimo edit notebooks/tutorial.py

Customizing parameters

The most important prettymaps.plot() parameters are:

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"]},
    },
)

Macau, custom parameters

See docs/tutorial.md for the full set of examples (Macau, Bom Fim, mosaic, Barcelona plotter, Tijuca, multiplot, hillshade, Garopaba keypoints).

prettymaps (marceloprates/prettymaps)

Searching Database…

这是什么?prettymaps 是一个 Python 库,可以基于 OpenStreetMap 数据绘制风格化的艺术地图。它结合 osmnx、matplotlib、shapely 和 vsketch,把街道、建筑、水域等要素渲染成自定义样式的图像。
这只是个库,还是也有应用程序?它主要是一个 Python 库,你通过 prettymaps.plot() 来调用。不过仓库里还附带一个可选的 Streamlit 前端(app.py),可以在本地运行,获得图形界面。
我该怎么安装,怎样做出第一张地图?可以用 pip 在本地安装,也可以在 Google Colaboratory 上安装并重启运行时,然后调用 prettymaps.plot(),传入 layers、style 和地点。marimo 教程笔记本和 Colab 演示会完整介绍整个流程。
它底层依赖什么?它用 osmnx 获取 OpenStreetMap 数据,用 matplotlib 进行渲染,用 shapely 处理几何图形,并用 vsketch 实现手绘风格的绘制。你只需要一个 Python 环境即可。
许可证方面有什么特别需要注意的地方吗?它采用 AGPL-3.0 许可证,允许商业使用、分发和修改,但你必须公开源代码,并保留署名信息。作者还明确禁止用 prettymaps 的输出铸造并销售 NFT,原因是此前有其他项目出现过滥用的情况。
绘制地图时可以自定义哪些内容?你可以控制 layers(要获取哪些 OSM 要素)、style(按图层设置的 matplotlib 样式)、presets(JSON 配置,如 'default'、'minimal'、'macao'、'tijuca'),还能通过 circle、radius 和 dilate 参数调整边界形状。
不用安装,在哪里可以直接试用?有一个 Google Colaboratory 演示笔记本,可以直接在浏览器中打开并运行,无需任何本地配置。
开始之前能先看看示例吗?docs/tutorial.md 展示了多个渲染示例,包括澳门、Bom Fim、巴塞罗那绘图仪、蒂茹卡、multiplot、山体阴影和关键点,每个示例都配有图片和代码。
Size
557 MB
Stars
14.3K
Age
5y
Commits · 90 Days