Skip navigation

In Tableau 2018.2 we introduced a change to how polygon edges and lines are represented on our maps. You can read about the details in Supporting advanced spatial analytics with changes to lines and polygon edges in Tableau, but the short story is that we’re making a switch to represent your spatial data using the semantics of the original data source. This change will not impact most spatial datasets – it will really only be noticeable for datasets with super long straight lines.


In this post I’ll explain a bit about how this change will impact your data, and will explain how to process your data to ensure that you have straight lines on Web Mercator if that is really what you want in your data.  Because, sometimes you really do just want long straight lines connecting two points on the map and you don’t need (or want) the shortest path on the Earth.


What do changes in line and edge rendering mean for visualizing your data?

When you have long, straight lines or polygon edges, you may see some curvature in them when you render them in Tableau.  That is because we are rendering the lines and polygon edges as either great elliptic arcs (shortest path on the ellipsoid) or as a straight line on a simple rectangular projection.


For an example of what you might see – if you had a straight line connecting the Los Angeles airport (LAX) and London-Heathrow (LHR) in earlier versions of Tableau you would see the red line below.  In 2018.2 and beyond, you would either see the blue line (great elliptic arc) or a straight line on a simple rectangular projection.  In this case, it turns out that that straight line is almost indistinguishable from the straight line on Web Mercator.



Here is how we are treating different file types:

  • Great elliptic arcs (SQL Server geography, KML) ,
  • Straight lines on the plate carrée projection, the simplest rectangular projection (Shapefile, MapInfo, GeoJSON, TopoJSON)



How to update your data to ensure that all lines are straight on Web Mercator

To make sure that all of the lines and polygon edges in your dataset appear as straight lines on the Web Mercator projection (what we use in our base map), all you need to do is add more vertices along the lines.  Then there aren’t any super long lines anymore because we’re rendering a bunch of shorter segments (short enough so that the great circle route and the straight line on Web Mercator are indistinguishable) instead of one super long line.


You can add new vertices to your polygons or lines with pretty much any geographic information system (GIS), spatial database, or coding library (e.g., for Python, R, etc.).


I like to go open source with my geospatial work, and I think the graphical interface in QGIS is pretty accessible for GIS users and non-GIS users, so I’ll use that for my example.



The steps:

  1. Open your spatial file in QGIS
  2. Re-project to Web Mercator
  3. Densify at a specified interval (this adds the new vertices)
  4. Map in Tableau


Here we go:



1. Start with a spatial file (I’m using an Esri shapefile).  Open it in QGIS.


My example here uses a dataset with paths from Seattle to several locations around the world.  I have added in a continent dataset in the background for spatial context.



Each of the lines is made up of exactly TWO vertices.  By default, these are all shown as long straight lines in the GIS.


  For reference, if I added the same file to Tableau 2018.2 or later, I would see those lines as either great elliptic arcs or as straight lines on a simple rectangular projection (Plate Carree) projected onto the Web Mercator projection. The lines that I end up with would depend on the data source – so if I add a shapefile, MapInfo, or GeoJSON file with these lines it would look like the map on the right (straight lines on the simple rectangular projection as projected in Web Mercator – note the really subtle curvature on the line segment connecting to South Africa).  If I add a KML or SQL server data source with these two vertex lines the lines would look like the map on the left (great elliptic arcs)



2. Change the projection for your dataset to Web Mercator


In order to add new vertices along our line segments to make sure they are straight lines in Web Mercator, we need to add the new vertices with the dataset in that projection.  To re-project the data to Web Mercator, I find the easiest option is to just do a Save As… on the dataset and set the projection for the new dataset.


Be sure to put the file somewhere you can find it again (the Browse button makes that easy…), and set the Coordinate Reference System (CRS) to Web Mercator (EPSG:3857).  I find the easy way to find Web Mercator is to hit the globe looking button next to the CRS drop down, and then in the CRS Selector window type ‘3857’ in the filter and QGIS will find it.


3. Now densify your dataset! 


There are two options for densifying geometry.  One is the standard ‘densify geometries’ that you can find in the menu under Vector -> Geometry Tools -> Densify Geometries.  But that only lets you specify how many new vertices to add per line.  That is sort of a waste for this, because there may be short lines where we don’t need to add any new vertices because they are already pretty short.  If we were to add new vertices it would unnecessarily bloat up the size of our file.


So, I like to use the ‘Densify geometries given an interval’ tool.  There may be easier ways to find it, but I just open the processing toolbox (Processing -> Toolbox) and search for densify and select the right tool:

Now I can select the interval at which I want to add new vertices.  I’ve never done the math to figure out the optimal spacing because I’m lazy, so I just picked 100km as a good distance.    Since the units in Web Mercator are meters, that means that our interval will be 100,000.


Make sure that you have the correct input layer selected.  It should have an EPSG of 3857 identified (that will confirm that your dataset is really in the Web Mercator coordinate system). Be sure to set the location where you want the newly densified dataset to be saved.  Click on the button with three dots next to where it says ‘Densified’ to specify the output location.



4. Add your newly densified dataset to Tableau and enjoy the results.


For comparison, here are three different versions of the same dataset:

  • Original data in KML (renders as great elliptic arcs)
  • Original data in Shapefile (renders as straight lines on a simple rectangular projection)
  • Densified data (renders as straight lines on Web Mercator)



Happy Mapping!