Creating your own custom maps
Map Art
Prettymaps combines multiple Python libraries to make it easy to draw maps straight from the OpenStreetMap database.
Maps are terribly important. Without maps we would not know where to go or, in many cases, what to do, either. Accurate maps are essential to planning anything – from a romantic weekend to large-scale urban projects. But maps are also beautiful in and of themselves. If they are customized by their owner, they can become little pieces of art. In this tutorial, I introduce a relatively simple way to generate such art using OpenStreetMap [1] and free and open source software. The results include maps in several styles and shapes that can be used as wall posters; illustrations in brochures and other documents; decorations for mugs, pillows, and other household items; or … just be used on the road, as good old paper maps!
OpenStreetMap
If you have used the Internet at all in the past 15 years, very likely you already know what OpenStreetMap is. But just in case you don't, here is a super-quick definition, focused on the aspect that is directly relevant for this tutorial: OpenStreetMap (OSM) is the Wikipedia concept applied to digital cartography, an online map of the whole world, built and continuously updated by thousands of volunteers from all around the world. It is hard to explain how important OSM is for our society, but anyone interested may find food for thought on this matter in my blog [2].
Here, what really matters is the fact that all the OSM raw data is available for reuse under an open source license and can be downloaded automatically through equally open programming interfaces. It's this availability that makes drawing custom digital maps possible, even for non-programmers and for commercial purposes.
prettymaps
The maps that you see in this tutorial have been generated with prettymaps [3], a Python package that can fetch selected raw data straight from the OSM database and then pass it to other libraries that will do the actual drawing according to your instructions. In my experience, prettymaps is a little gem that can make map enthusiasts happy, in spite of a couple of drawbacks.
The minor drawback is that prettymaps is slow. Drawing a relatively small map may take several minutes, even on an Ubuntu desktop with 16GB of RAM. Then again, this is software that many users will only run occasionally (and always in the background, maybe while taking a nap), so it's not really a big deal.
A bigger obstacle, at least as of this writing, is the fact that the only documentation is the raw code examples present on the Jupyter Notebook [4] and GitHub pages [5] of the author and other users of prettymaps. Don't despair, though! This tutorial explains how to install prettymaps and then how to modify any of those examples to draw any place you want, even if you have never used Python before. In order to get there, however, it is necessary to start with a quick overview of the prettymaps workflow and main components, as well as some basic concepts of digital mapping.
What Are Digital Maps?
Under the hood, OSM and any other digital map are standard relational databases, with some extra data types and functions made-to-order to support mapping. Such databases are usually called geographic information systems (GIS). How the data is actually presented to users (i.e., how any map built with GIS actually looks like on a screen) is delegated to separate programs. Maybe the first essential feature of any GIS is that all data is organized in layers, one (or more) for every terrain-related feature: streets, buildings, forests, water (rivers and lakes), railroads, shops, sewers, administrative boundaries, and hiking paths. All these features, and many more, have their own separate layer that users can show, hide, mix, or visually format as they wish.
Second, GIS databases support storage and analysis of lines and polygons. This is what makes it possible to, for example, draw state or city borders, calculate the length of an itinerary or the area of a building, represent the exact shape of a lagoon, or figure out which parts of a mountain range belong to one country or another.
Third, each point of each element in the database may also have an elevation, its height above or below sea level. Among other things, this permits the user to calculate steepness of roads and draw 3D maps.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.