Tableau Geospatial: Merging SHP Files in QGIS

Tableau Geospatial: Merging SHP Files in QGIS

This is second post in our Tableau geospatial series.  The first described Polygons, Lines and Points.  This post will describe how to merge multiple shapefiles in QGIS.


Multiple Shapefiles

For this example, I am going to show you how I created the Bathymetry layers in my Sharknado Recreation Viz.

According to NOAA, The term “bathymetry” originally referred to the ocean’s depth relative to sea level, although it has come to mean “submarine topography,” or the depths and shapes of underwater terrain.

I figured for the #IronViz competition everyone would map something on land so at some point I started focusing on the ocean.  After all, about 71% of the earth’s surface is covered by water.

1.  Go to Natural Earth Data, scroll down to Bathymetry and select Download All.  This will be a zip file.  Unzip it.  This folder will contain 72 files.  We are primarily interested in the 12 shp files.

2. Open QGIS add all 12 shp files as vector layers. *note –  installation instructions were in the last post

It should look something like this.  I know it’s kind of ugly, we’ll fix that.

3. Now we need to add a new field to our data.  These particular shapefiles have an attribute called depth that we could use as a dimension in Tableau, but in my case I was going to merge this with shapefiles other than these bathymetry layers.  So I wanted to add a new field called layer to all the files.

Right click on the first layer and select open attribute table.  Click on the pencil to edit and then click on the Add field button.  Enter the field name, data type and length.

4. Next select the new field from the dropdown.  Click on the E to open the formula editor and to write the formula you want to add.  You will see a preview at the bottom.  Click Ok and then Update All.  Finally, click on the pencil to close the attribute table and save.  Repeat this for all the layers.

5.  After you add the new field to all the layers, it is time to merge them.  Select Vector->Data Management Tools->Merge Vector Layers.

Open the layers to merge dialog, select all and hit OK.

Now open the Merged dialog and select save to file and browse to where you want to save it. Hit Run.  You can alternatively do MMQGIS->Combine->Merge Layers.


Back to Tableau

1. Connect to the merged file you just saved above.  Drop Geometry on the marks card.

2. I am going to put the Layer field we created on color.  I first assigned colors from the blue-teal palette so the colors would go light (0m) to dark(10000m).  I then sorted the layers in descending order manually.  The sort is because the 0m layer covers the entire ocean.  These layers are meant to be stacked.  Next turn off the border and halo options under color and dial opacity to 40%.  Now you are starting to get a sweet map!

3. The rest is a bit of map styling within Tableau.  I went to Map->Map Layers and unchecked all the map layers.  I left the Tableau map on light so the layers would be highlighted in black as you hover.  Next change the pane shading on the sheet to something else.  I chose purple.

That’s it.  I hope this was helpful.  If I got anything wrong, let me know.

One thought on “Tableau Geospatial: Merging SHP Files in QGIS

Leave a Reply