From Osaka to Johannesburg by bike

Hey, this is Eddie from the support team at Datawrapper. The team seems to be fascinated by maps lately, so I decided to follow Margaux and Becca’s lead and make maps for the third Weekly Chart in a row. This week, I looked at bike lanes in several cities around the world to see how much space they take up.

Lately, I’ve become quite interested in how people are claiming the streets back from cars. One of the ways to achieve this is through bike lanes. In Madrid, where I grew up, these are rare to see and you are considered courageous if you venture through the city center with your bike. A 2017 survey ranked Madrid as the worst city for cycling in Spain. Aggressive traffic and very few bike paths make the capital a dangerous zone for cycling enthusiasts.

The good news is that most of the world’s cities show a very different picture, and are making room on their streets for walkers and cyclists. This became especially true during the pandemic. Several cities created temporary bike lanes to give more space to cyclists and pedestrians so that they could move around while maintaining social distance. General concern for our planet has also led more people to take up cycling, or at least get interested in it. The British newspaper The Guardian even has now a biking blog.

To get a better understanding of how much space different cities around the world leave for their cyclists, I decided to visualize bike lanes in America, Europe, Africa, Asia, and Australia, and compare the length of the routes to the cities’ populations. Here are the results:

Looking at these numbers, I was not surprised to learn that cities like Amsterdam, Berlin, and New York are a paradise for cyclists. That said, I was saddened to discover the lack of data for many cities in Africa and Latin America, which makes it difficult to get a fuller picture of the situation.

How can you create these maps?

The maps above are one of the three map types you can create in Datawrapper: locator maps. While I have some experience with this map type (like this one showing dams on the Nile), I had never created a locator map showing routes — so I had a lot to learn this week. If you want to create them as well, I would recommend you start by reading these articles from our Academy, which were a big help to me:

  • How to create maps using GPX files — This one shows you how to create a map of bike routes and hiking trails. You'll end up with a map formatted as a GeoJSON file, which can be imported to Datawrapper as a custom marker.
  • How to import area & line markers — This article gives more detail on how to import a custom GeoJSON to Datawrapper, and explains the prerequisites your file needs to meet.
  • How to upload your own map — Although this article is specific to symbol and choropleth maps, it contains an overview of Mapshaper, a tool that I also used for this project.

And now, on to the process!

Step 1: The data

Before I could create the maps, I had to first get the spatial files for the bike lanes. For this, I used Overpass Turbo, an API that allows you to query the entire OpenStreetMap database and get selected parts of the map back.

First, you'll look for the area that you want to query: for example, Madrid. Then, you'll write the query in the console, and click on execute The query I used looks for routes that are specific to bikes. That's the parameter ["route"="bicycle"].

[out:json][timeout:25];
( 
  way["route"="bicycle"]({{bbox}});
  relation["route"="bicycle"]({{bbox}});
);
out body;
>;
out skel qt;

Step 2: Cleaning

Once I got the file of bike lanes, I had to trim them so that they fit the area for each city. I used Mapshaper for this purpose. This tool is free and open-source, and you can use it directly in your browser to convert, edit, and simplify geospatial files.

First, I uploaded two files: one containing the bike lanes, and one I downloaded with the outline of each city (which I called region), as a reference for the trimming. Then, I ran the following command:

-clean
-clip region
-dissolve

Clip removes the lines that didn't fit my map, and dissolve combines all the lines into one object.

Finally, I had to calculate the total length of the lines so that I could get an idea of how many kilometers each city dedicated to bike lanes. For that, I used the following command:

each 'len=this.length'

Before exporting the trimmed lanes, I simplified them directly in Mapshaper to make sure the GeoJSON was under 2MB, which is the maximum size you can upload into Datawrapper. After clicking on Simplify at the top right corner, make sure you select prevent shape removal so that the features of your map won't disappear from oversimplification.

Step 3: The maps

Once I had all of my files ready, creating the nine maps in Datawrapper was very simple. I first searched for each city in Add region as an area marker. After that, I imported my GeoJSON containing the bike lanes. I styled the map using different colors and in step 3: Visualize, I selected roads under Map styles for some additional context. Although you might be familiar with the shape and size of some of these cities, others might be completely new to you, so I thought that would help!

I hope that gives you a better idea of how you can show routes in our locator maps. If you try this out and have any questions, don't hesitate to send me an email!


That's all from me this week! Thanks for reading, and I hope you learned a bit more about bike lanes around the world. Don’t hesitate to share your thoughts with me at edurne@datawrapper.de or my Twitter, @edurnemg. Special thanks this week to our cartographer Anna, who helped me a lot with Overpass Turbo and Mapshaper. Next week, it will be our writer Rose's turn to write a Weekly Chart. She also proofread this text and gave me feedback for the blog post, so big thanks for that!

Resources

I hope you've all been enjoying your local bike lanes during the pandemic! Here are some resources to learn more about urban mobility around the world:

  • Last year the Spanish newspaper El País published a great article on bike lanes, and how cities around the world were adjusting them during the coronavirus pandemic
  • My collague Aya, also from the support team, wrote another article about bike routes, specifically, the EuroVelo, a network of 16 bike routes around Europe. You should bookmark this for your next bike trip!
  • Lastly, my friend Vincent (@vincent_thorne) is currently doing a PhD in Urban and Development Economics, and one of his favorite topics of research is — yes, you guessed it — biking. He's about to publish a paper on how bicycle-sharing is making our cities cleaner. Keep an eye on his blog if you want to read it!

Comments