• garycollins24

This Beautiful World Blog 4 | Mapping of an Iconic Driving Road | From Kranjska Gora to Soca

Welcome to blog number 4 in my series entitled "This Beautiful World" where I am covering my recent learnings in mapping using Mapbox and Tableau. In blog 2 I focused on how small changes in colours can have a big impact and make your maps POP!, and in blog 3 I focused on how to create long shadows in Mapbox to give your maps a great look and feel. If you haven’t read these previous blogs, I would recommend reading these first, along with the introduction to this series.


In this blog I am going to focus on how to map a road.

The Thinking Behind the Viz

I had an idea about showing an iconic road or journey on a map, and how I could visualise it. I thought about showing the path of Route 66 across America, and I was also interested to see what the Great Wall of China would look like on a Viz. I then had an idea of mapping one of the iconic drives across the Alps as that would allow me to show both a road on a map, and also experiment further with Mapbox to highlight some of the local details around it. I started to do some research about iconic drives across the Alps, and one that featured on a ‘must do’ list was the journey from Kranjaska Gora to Soca in Solvenia. Perfect!

I knew I could create a map in Mapbox, but my challenge was being able to get the coordinates for a road or journey – it would be thousands of data points – it certainly wasn’t going to be manually calculated…

Building the Viz


There were 2 parts to this viz. Firstly, getting the data to be able highlight a road on a map, and secondly creating a Mapbox map . In my 2 previous blogs I have walked through a couple of examples of how I have been building maps in Mapbox, and then bringing them in to Tableau so for this blog I am going to focus mainly on how to highlight a road on a map.

I spent a lot of time searching the internet for data sets of roads and journey’s for this viz. I really struggled to find anything. I then went onto Google maps to see what I could do there – surely Google Maps must be able to help me! Well bingo!

On Google maps, it enables you to download all the coordinates for any route you want, anywhere in the world – here is how:

Head on over to Google maps

Click on "My Places", then on the "Maps" tab click "Create Map" at the bottom of the page

From the toolbar under the search bar click on "Draw a line". Google Maps gives you the choice to map a Driving, biking or walking route. For the purposes of this viz I picked Driving.

Type the name of the starting point you want to get directions for – in my case, it was Kranjska Gora.

You will notice a new layer appear at the bottom of the white box to the left:

Type into the box A the starting point, and box B the ending point, and then the map will update, showing the route:

When you are happy with your route click on the 3 dots to the right of the map's name and select "Export to KML/KMZ"

If you have mapped various routes on the one map, change the option "Entire map" to just the route you have selected and "Download" as KML.

Open the KML file in your preferred text editor, and scroll down until you see the coordinates. Here I have used TextEdit on a Mac:

Copy all of the coordinates, and then put these into excel.

Then separate out the coordinates into 2 columns using text to columns function, using comma as the separator. Lastly, run a sequential set of numbers into a third column entitled 'Path'. This 'Path' column is what you will use in Tableau to draw the line. Your screen should look like this:

Now, save the file, and then connect this excel sheet into Tableau.

Now go onto a worksheet and assign a Geographic Code of Longitude to Y and Latitude to the X fields.

Ensure the ‘Path’ field is a Dimension, not a Measure..

Click on the X and Y fields to bring them into the view. Change the Mark to a Line, and then drag the ‘Path’ field onto Path in the marks card. You should now have a view that looks like this:

Congratulations, you have now successfully mapped your route in Tableau! Now you have your route, you can choose what ever map you like to visualise it on. Tableau has a range of standard map types you can use in the Map>Background Map path from the title bar.

I wanted to create another Mapbox map as my background, as I wanted to experiment with having the mountains of the Alps as the main feature of the map of the Viz, but also to include a faded view of the satellite layer showing the towns and fields. Here is the map I created:

I used a similar approach as I have described in my previous 2 blogs with building up a series of layers and experimenting with the different colours. The difference in this map was that I on the Mapbox-satellite layer I reduced down the Raster Opacity to 0.5. This had the effect of making the satellite layer more subtle, giving a view of the towns and fields, but making sure they didn’t dominate the map.

I spent a lot of time playing with various colours for this map. I ended with what is quite a ‘heavy’ feel in the dark green. I am still not sure if I fully like the final colour, but I couldn’t come up with anything else I preferred at the time, so I went with the motto that ‘Done is Better than Perfect!’.

After I had finished the Mapbox map, I brought this into Tableau and used it as the map for the view I have already created for the road from Kranjska Gora to Soca.

There you go – how to highlight a road anywhere in the world, and create a Mapbox map to visualise it on!

I hope this has been useful to you. See you soon for Blog 5 where I will walk though my learning journey blending maps into the background colour of a viz:


Keep vizzing, see you soon!

@garycollins24

0 comments