Skip to main content

Create beautiful maps from OpenStreetMap data

Project description

prettymapp 🖼️

Prettymapp is a webapp and Python package to create beautiful maps from OpenStreetMap data


🎈 Try it out here: prettymapp on streamlit 🎈



Based on the prettymaps project

Prettymapp is based on a rewrite of the fantastic prettymaps project by @marceloprates. All credit for the original idea, designs and implementation go to him. The prettymapp rewrite focuses on speed and adapted configuration to interface with the webapp. It drops more complex configuration options in favour of improved speed, reduced code complexity and simplified configuration interfaces. It is partially tested and adds a streamlit webapp component.

Running the app locally

git clone https://github.com/chrieke/prettymapp.git
cd prettymapp
pip install -r streamlit-prettymapp/requirements.txt
streamlit run streamlit-prettymapp/app.py

Python package

You can also use prettymapp without the webapp, directly in Python. This lets you customize the functionality or build your own application.

Installation:

pip install prettymapp

Define the area, download and plot the OSM data:

You can select from 4 predefined styles: Peach, Auburn, Citrus and Flannel.

from prettymapp.geo import get_aoi
from prettymapp.osm import get_osm_geometries
from prettymapp.plotting import Plot
from prettymapp.settings import STYLES

aoi = get_aoi(address="Praça Ferreira do Amaral, Macau", radius=1100, rectangular=False)
df = get_osm_geometries(aoi=aoi)

fig = Plot(
    df=df,
    aoi_bounds=aoi.bounds,
    draw_settings=STYLES["Peach"],
).plot_all()

fig.savefig("map.jpg")

You can also plot exported OSM XML files e.g. from openstreetmap.org:

from prettymapp.osm import get_osm_geometries_from_xml

df = get_osm_geometries_from_xml(filepath="Berlin.osm")
aoi_bounds = df.total_bounds
...

Customize styles & layers

Edit the draw_settings input to create your own custom styles! The map layout can be further customized with the additional arguments of the Plot class (e.g. shape, contour_width etc.). Check the webapp examples for inspiration.

from prettymapp.settings import STYLES

custom_style = STYLES["Peach"].copy()
custom_style["urban"] = {
    "cmap": ["#3452eb"],
    "ec": "#E9724C",
    "lw": 0.2,
    "zorder": 4,
}

fig = Plot(
    df=df,
    aoi_bounds=aoi.bounds,
    draw_settings=custom_style,
    shape="circle",
    contour_width=0,
).plot_all()

You can also customize the selection of OSM landcover classes that should be displayed! Customize the default settings or create your own dictionary! See settings.py for the defaults.

from prettymapp.settings import LANDCOVER_CLASSES

custom_lc_classes = LANDCOVER_CLASSES.copy()
custom_lc_classes["urban"]["building"] = False # drops all building subclasses
custom_lc_classes["grassland"]["leisure"] = True # Include all leisure subclasses
custom_lc_classes["grassland"]["natural"] = ["island"] # Selects only specific natural subclasses

df = get_osm_geometries(aoi=aoi, landcover_classes=custom_lc_classes)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prettymapp-0.5.0.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

prettymapp-0.5.0-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file prettymapp-0.5.0.tar.gz.

File metadata

  • Download URL: prettymapp-0.5.0.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for prettymapp-0.5.0.tar.gz
Algorithm Hash digest
SHA256 74cc891379813568e31dc259496e7c62392a9138b04e904a371e4e1fff67f53e
MD5 3ba71052c9ca08c176e9fe1b9d553791
BLAKE2b-256 2a1d2eed92b38b9a1ee369dda82c060b6f0a94a1a3f7938580b23b17afa38a3b

See more details on using hashes here.

File details

Details for the file prettymapp-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: prettymapp-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for prettymapp-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c0fa1edd4606a3545062f9694b7430acc15910e2cb32826239bccdd9fa16c5f
MD5 5f15d4f080fb7285fd255df4a97c6c84
BLAKE2b-256 ba7db6f2fc3dd4d1f403d25a10ccd918de508b6d55b6c5764a12c265f6921c02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page