Geo Midpoint in Tableau

Last year I did several blog posts on geo-optimization in Tableau using R. My first blog post Dynamic Geo-Optimization in Tableau Using Integration with R with a sample video and a description of how this might work. The original R code is from R-Bloggers posted here. In November, Silke Govaert from Datatonic, emailed me. Based on my work, she had implemented this in Tableau and together we posted a full instructional post here. This method requires a connection to R. It runs an optimization based on the latitude and longitude of points taking into account some sort of weighting.

This past week, I had several people ask me about finding the center point for a group of points on a map using Tableau without R. There are several methods for finding a geo midpoint. They are outlined here. One of the methods that is described uses the averages of the latitude and longitude. This method assumes a flat earth. It gives a close approximation of points when they are within a close distance of each other (ex. 250 miles).

The advantage of using this method in Tableau is 1.) this is really fast and 2.) it doesn't require any knowledge or setup of R. The points on the map can be selected in the same manner as when using R and the midpoint is recalculated on the fly based on those selected points. Below is an example on Tableau Public or click here to download the Tableau Workbook.

Here are the steps to create this visualization.

Step 1: Open Tableau and load some data

Required fields are Latitude, Longitude and some sort of ID/Dimension. For example, I am using 3 fields from crime data in Cincinnati that has Latitude, Longitude and Incident No. Download an example data file here

Note - make sure to remove NULL values from your data source, otherwise the center point will show in different locations.

Step 2: Build Maps

"Points" Map
   Move Incident No from Measures (green pill) up to Dimensions (blue pill)
   Move Longitude to Columns
   Move Longitude to Rows
   Move Incident No to Details
   Pin Map to the current locations

"Center" Map
   Create new Worksheet
   Move Longitude to Columns
   Move Longitude to Rows
   Move Incident No to Details
   Pin Map to the current locations
   Remove Incident No

Step 3: Build Dashboard

   Create New Dashboard
   Move Points Map onto Dashboard
   Move Center Map onto Dashboard
   Select Dashboard -> Actions and create new "Filter Action"
   Select Points Map in the Source Sheet and Center Map in the Target Sheet
   Click "OK"
   Click "Add Action" and select "URL"
   Select "Center" map in the Source Sheet
   Enter this Google Maps URL in the URL box:

Format as desired
   On "Center" map, drag Latitude and Longitude to the Labels
   Change color of dots and size as desired

You should now have a dashboard with two maps, one with all the points and the other with the center of those points based on the latitude and longitude of all of the points. Use the "Select A" keyboard shortcut on the "Points" map and select whatever points you wish. The "Center" map will recalculate based on the points selected. If you click on the center point on the center map, it will link directly to a Google Maps page using the latitude and longitude so that you can view the center point on Google Maps.

I hope you find this information useful. If you have any questions feel free to email me at Jeff@DataPlusScience.com

Jeffrey A. Shaffer

Follow on Twitter @HighVizAbility