Skip to main content

A simple python library to draw pretty maps from OpenStreetMap data

Project description

prettymaps

A minimal Python library to draw customized maps from OpenStreetMap data.

Based on osmnx, matplotlib, shapely and vsketch libraries.

Important:

Buy Me a Coffee at ko-fi.com

  • I've made the plot function print by default a message in the corner containing the mandatory OpenStreetMap credit and the link to this repository. Please keep it.
  • You can make commercial use of prettymaps drawings, but I ask that you credit OpenStreetMaps and myself.
  • Share your creations on the prettymaps subreddit

As seen on Hacker News:

Read the docs

Google Colaboratory Demo

Open In Colab

Installation

Install with

$ pip install git+https://github.com/abey79/vsketch#egg=vsketch
$ pip install git+https://github.com/marceloprates/prettymaps.git

Usage example (For more examples, see this Jupyter Notebook):

# Init matplotlib figure
fig, ax = plt.subplots(figsize = (12, 12), constrained_layout = True)

backup = plot(
    # Address:
    'Praça Ferreira do Amaral, Macau',
    # Plot geometries in a circle of radius:
    radius = 1100,
    # Matplotlib axis
    ax = ax,
    # Which OpenStreetMap layers to plot and their parameters:
    layers = {
            # Perimeter (in this case, a circle)
            'perimeter': {},
            # Streets and their widths
            'streets': {
                'width': {
                    'motorway': 5,
                    'trunk': 5,
                    'primary': 4.5,
                    'secondary': 4,
                    'tertiary': 3.5,
                    'residential': 3,
                    'service': 2,
                    'unclassified': 2,
                    'pedestrian': 2,
                    'footway': 1,
                }
            },
            # Other layers:
            #   Specify a name (for example, 'building') and which OpenStreetMap tags to fetch
            'building': {'tags': {'building': True, 'landuse': 'construction'}, 'union': False},
            'water': {'tags': {'natural': ['water', 'bay']}},
            'green': {'tags': {'landuse': 'grass', 'natural': ['island', 'wood'], 'leisure': 'park'}},
            'forest': {'tags': {'landuse': 'forest'}},
            'parking': {'tags': {'amenity': 'parking', 'highway': 'pedestrian', 'man_made': 'pier'}}
        },
        # drawing_kwargs:
        #   Reference a name previously defined in the 'layers' argument and specify matplotlib parameters to draw it
        drawing_kwargs = {
            'background': {'fc': '#F2F4CB', 'ec': '#dadbc1', 'hatch': 'ooo...', 'zorder': -1},
            'perimeter': {'fc': '#F2F4CB', 'ec': '#dadbc1', 'lw': 0, 'hatch': 'ooo...',  'zorder': 0},
            'green': {'fc': '#D0F1BF', 'ec': '#2F3737', 'lw': 1, 'zorder': 1},
            'forest': {'fc': '#64B96A', 'ec': '#2F3737', 'lw': 1, 'zorder': 1},
            'water': {'fc': '#a1e3ff', 'ec': '#2F3737', 'hatch': 'ooo...', 'hatch_c': '#85c9e6', 'lw': 1, 'zorder': 2},
            'parking': {'fc': '#F2F4CB', 'ec': '#2F3737', 'lw': 1, 'zorder': 3},
            'streets': {'fc': '#2F3737', 'ec': '#475657', 'alpha': 1, 'lw': 0, 'zorder': 3},
            'building': {'palette': ['#FFC857', '#E9724C', '#C5283D'], 'ec': '#2F3737', 'lw': .5, 'zorder': 4},
        }
)

Gallery:

Barcelona:

Heerhugowaard:

Barra da Tijuca:

Porto Alegre:

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

prettymaps-0.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prettymaps-0.1.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file prettymaps-0.1.2.tar.gz.

File metadata

  • Download URL: prettymaps-0.1.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for prettymaps-0.1.2.tar.gz
Algorithm Hash digest
SHA256 de1aaabd0680b5283dc18d84e5d37d3f990fd4d25598eb7d57ccea042b47e9c8
MD5 c135af8958df7ad2e5e27d2bd4e2ebf6
BLAKE2b-256 b73c0e00edaaa70f99f227f62d920c5a5715cd6b9a9e162ff89e8e632925199d

See more details on using hashes here.

File details

Details for the file prettymaps-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: prettymaps-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for prettymaps-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d66ffeb3b18ba2c060d93f42bf3c28c927b9c67457fd1cf24ce1a5fb8a58d84a
MD5 c4b76639e70b3e41a92ec81e664121c8
BLAKE2b-256 074f0515eed2a7ec36bc3f2ec7011859ceea4efdc7103e62cc1e1452be32ef6c

See more details on using hashes here.

Supported by

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