In Part I: map projection basics, we took a look at what map projections are in general, learned about the map projection that is used in the Tableau base map (Web Mercator), and saw a few examples of what a single dataset represented in different coordinate systems would look like if it were drawn in the Web Mercator coordinate system.

In Part II, we’re going to walk through an example of how you can move away from the Web Mercator projection with some creative data adjustment.

 

Ingredients needed:

  • A spatial data file (Shapefile, JSON, etc.) [the example data that I used came from Statistics Canada]
  • QGIS – a FREE and open-source Geographic Information System (or you can use whatever GIS, database, programming language, or other tool you prefer for manipulating spatial data…there are plenty of options)

 

Caveats:

  • If you use this trick you will need to make the Tableau basemap fully transparent (it has to disappear) or make your own custom tiles in Mapbox.  It’s best if the dataset you are working with is polygons that are familiar enough in shape that you don’t need the extra spatial context provided by the Tableau base map.

 

  • You will not be able to use the Tableau Map Search.  Remember from Part I, we are going to move things around on the base map, so if you search for a location Tableau will take you to where that spot is in Web Mercator coordinates, which may be very different than where your data is on the map. But, you can use filters or a highlighter to allow people to find locations based on a dimension in dataset (so, in a sense, create your own custom map search based on the locations in your dataset).

 

So, now let’s dig in and see how this all works!

 

Open your spatial file in QGIS.  Click on Layer -> Add Layer -> Add Vector Layer and select the .shp file, or other spatial file format of choice, that you want to work with (either your own file or the example data file linked above)

partII_qgis_addLayer.png

 

 

Check the projection of your dataset.  The short story here is that so long as you have a projection defined (and that it is correct), you are good to go.  If you want to know more about the projection of the dataset you are working with you can right click on the listing for your dataset in the legend on the left side of the QGIS window and select Properties.  In the properties window, look under General and Coordinate reference system.

 

partII_qgis_checkPrj.png

 

The Coordinate reference system information for our sample file tells us that this is “EPSG:4269 – NAD83.”  Whaaaa? This information is actually pretty simple to decode once you know the trick:

EPSG = European Petroleum Survey Group.  They catalogue definitions for map coordinate systems and assign each a unique reference code.

4269 = The reference code for this particular coordinate system.  You can get more information at the for this particular code at the spatialreference.org website

NAD83 = North American Datum of 1983.

 

You can also find more information about the coordinate system by looking at the metadata properties:

partII_qgis_prjProperties.png

 

What I read here is that the dataset has a bounding box that is within the range I would expect for latitude and longitude (longitude: -180 to 180, latitude: -90 to 90), so even if I didn’t know that the dataset was in EPSG:4269 I could make a good guess that it was just plain ol’ latitude and longitude coordinates.

 

 

Project your dataset into your preferred coordinate system.  We could bring this Shapefile into Tableau directly using the spatial file support in 10.2…and it would work just fine:

partII_shpInTableau.png

 

But…I assume that since you’re reading this, you really want to see the data in a different coordinate system – like, perhaps, the coordinate system recommended by Statistics Canada (like the Statistics Canada Lambert, which happens to be defined by EPSG:3347).

To update the projection for our dataset, right click on the dataset name in the legend on the left side of the QGIS window and select ‘Save As…’

 

partII_qgis_saveas.png

Give the file a new name, and change the CRS to ‘Selected CRS’ and then click on the ‘Change…’ button.  This will open the Coordinate Reference System Selector (shown on the right below).  Find the coordinate system that you want to use – I just typed in the EPSG code (3347) because I happened to know it.  Otherwise you can scoll through the large number of coordinate systems supported in QGIS and select the one you like.

partII_qgis_saveAsChangePRJ.png

 

Check out the properties of your new file.  If you look at the properties for the new file that you saved, you should see updated information for the coordinate system and for the bounding box listed in the metadata.  Use the same steps we used in #2 above. 

Note how much larger these coordinates are and that the definition states that the coordinates are now provided in ‘m’ (meters)

partII_qgis_layerProperites.png

 

If you open a new file in QGIS and add this file, you’ll also notice that it looks different than the original:

partII_twoCanadas.png

 

Note that we could bring this NEW file, in the new coordinate system, into Tableau 10.2 and it would also work just fine.  Tableau is smart enough to look for the projection definition in your file and do the conversion to put it into the same coordinate system as our basemap.

 

partII_canadaInTableau.png

 

Now we get to the fun part...Tell a little white lie with your data.  We’ve seen above that Tableau will take a projected Shapefile and convert it into Web Mercator coordinates to match our basemap.  But, sometimes we don’t want Web Mercator.  So, here is where the fun comes in.  We make our data think that it’s in Web Mercator so that it will use that coordinate system when it draws.

 

DISCLAIMER
You want to be really careful here – you’re about to edit your Shapefile so that it has the wrong coordinate system listed for it.  Label this file carefully; you do not want to accidentally try to use this in analyses outside of Tableau.  We really are telling a white lie with data here and this is just a trick so that you can have a different ‘shape’ map in Tableau for visual analysis, it is not a pathway to success in spatial data analysis. 

 

Now that I’ve gotten that out of the way, we will continue with the process of little white data lies.

 

Open the properties for your newly projected file (right click on the name -> properties) and where it says that the Coordinate reference system is EPSG:3347 – NAD83 / Statistics Canada Lambert…go ahead and click Specify and just change that to WGS84 / Pseudo Mercator (EPSG: 3857).

 

partII_updatePrjToWM.png

 

What that did was update the text that defines the coordinate system for your dataset. It did not actually change the coordinate system, it just changed what the file thinks its coordinate system is.

 

Now you need to save a new copy of the Shapefile (right click -> Save As…) to make sure that the new definition is saved.  When I do this, I like to append some information in the file name to remind myself that this is a faux Web Mercator file.

 

Now what will happen if we add this new file to Tableau??

 

We have our newly projected data available in maps!

partII_prjCanadaInTableau_noBaseMap.png

Granted, you need to make the basemap transparent so that you don’t see that this is just a little data trick…

partII_prjCanadaInTableau.png

 

Why would we want to do this?  Check out a side-by-side comparison of the data in Web Mercator coordinates vs. Statistics Canada Lambert… The distortion on Web Mercator makes a big difference in the visual for this dataset!

Canada.png

 

 

Using this trick you should now be able to see and understand (and communicate!) using projected spatial data in Tableau.