A minimal Python library to draw customized maps from OpenStreetMap created using the osmnx, matplotlib, shapely and vsketch libraries.
 
 
Go to file
Christoph Rieke 3066525032 explicit imports, cleaned up, remove comments, clean up 2021-08-28 20:57:51 +02:00
.devcontainer Add devcontainer 2021-08-26 17:14:27 +00:00
.github Create FUNDING.yml 2021-08-27 16:01:12 -03:00
assets/Permanent_Marker Updated 'setup cell' to avoid errors with missing .ttf and /prints folder for colab notebook 2021-08-25 22:46:27 -03:00
notebooks Cleared outputs from 'installation' cell in examples.ipynb notebook to ease visualization in nbviewer 2021-08-28 14:24:54 -03:00
prettymaps explicit imports, cleaned up, remove comments, clean up 2021-08-28 20:57:51 +02:00
prints Re-added prints 2021-08-27 00:16:22 -03:00
script Add devcontainer 2021-08-26 17:14:27 +00:00
.gitignore Add devcontainer 2021-08-26 17:14:27 +00:00
LICENSE Initial commit 2021-03-05 09:22:05 -03:00
README.md Merge pull request #11 from kinow/patch-1 2021-08-28 13:13:30 -03:00
setup.py Updated setup.py 2021-08-23 22:50:04 -03:00

README.md

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.

As seen on Hacker News:

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

Barcelona:

Heerhugowaard:

Barra da Tijuca:

Porto Alegre: