Some scripts to generate nice maps using OSM data in Python and R
Cartograpy is the python version of these scripts. It's set up to be run from the command line.
But first, it's important to note that cartograpy relies on some pretty finicky modules, and hasn't been tested on multiple versions. It works fine on:
python
version2.7.14
overpy
version1.1
matplotlib
version2.1.1
fiona
version1.7.10
geopy
version1.11.0
Note also that it depends on the now deprecated mpl_toolkits.basemap. I'll hopefully update soon to run on cartopy instead.
- Clone or download this repository from github
- Navigate to the cartograpy foler in the directory your just downloaded in the command line (Windows) or terminal (Mac and Linux)
- In the command line, run
python cartograpy.py
This will create a map of Santa Barbara's roads (the default):
But wait! Maybe you don't want a map of Santa Barbara! Maybe you prefer another city? You can use the -c
or --city
argument to specify which city you want plotted. Let's try with Denver, Colorado:
python cartograpy.py -c "Denver CO"
It takes a while to download these roads, as it's a pretty big city. The output looks like:
That's a lot of roads! No wonder it took so long to download... You can use the -r
or --roads
argument to specify which road types you want. You can pick from 'trunk', 'motorway', 'primary', 'secondary', 'tertiary', 'unclassified','residential', and or 'service' roads.
Let's try with just trunk, primary, and residential roads:
python cartograpy.py -c "Denver CO" -r motorway trunk primary residential
This is much faster. You end up with:
You could also specify whether you want a png or pdf output with the -e
or --extension
argument. This would get you the same map but as a pdf:
python cartograpy.py -c "Denver CO" -r motorway trunk primary residential -e pdf