8/6/2018
Importing and Changing Spatial Information for Tableau
Tableau has the power to import and plot plenty of spatial file varieties. This consists of shapefiles (polygon, line and factors), GeoJSON and KML information. That is very helpful and makes it very straightforward to import and create a map. The truth is, as soon as imported into Tableau a easy double-click of the Geometry tablet will plot the spatial file on a map. It is actually that straightforward. Nevertheless, as a result of construction of a few of these information, you might want to convert your information to a distinct format. Let’s stroll by an instance.
Making a Customized Map Route
I’ve a brief working/strolling route by my neighborhood that I like (with a number of variations). I haven’t got a Fitbit or something that tracks my location, so the very first thing I wanted to do was map the route. There’s a useful gizmo from Google that makes this very straightforward, and it is free. Merely open Google.com/mymaps and provides it a attempt.
Listed below are the steps to create a customized route utilizing Google.
Choose « Create New Map » and enter your beginning location within the handle bar.
Choose « + Add to map »
Choose the « Add Marker » icon on the toolbar.
Click on on the map for the placement of the factors that you just want to add. You’ll be able to maintain the CTRL key down to pick out a number of factors rapidly alongside a path. The factors will robotically sequence for you, which will probably be vital once we import into Tableau.
Add markers for the entire location factors you want to add. When you’re accomplished, merely click on the final level a second time.
You’ll be able to click on on « Untitled Map » to call your map. This will probably be saved in your Google account for later (assuming you’re logged in).
Click on on the three dots to the proper of your map identify for choices and choose « Export to KML/KMZ » (It can save you as a KML or GeoJSON)
Choose the Map Layer within the dropdown field that has your factors. Notice – Tableau will solely work with KML information which have a single map layer (a minimum of as of Tableau 2018.2).
Examine the « Export to .KML file » checkbox and click on the obtain button.
You now have a KML file that’s prepared for import into Tableau. Merely open a brand new knowledge supply in Tableau and choose « Spatial file » and choose the brand new file. The steps for plotting the map in Tableau are fairly easy.
Double click on Geometry and your customized factors will probably be plotted on a map.
On the Marks Card, change the dropdown field from Computerized to Line.
Transfer Identify to Path.
It is best to now have a path mapping the factors within the route. Right here is my customized map route imported into Tableau as a KML file.
Animating the Route
Animating the route can be fairly straightforward. We are going to use the Web page Shelf for this.
Transfer Identify to the Web page Shelf
On the Marks Card, change the dropdown field from Line to Circles.
On the Play Management, choose the field « Present Historical past »
On the Present Historical past Choice, click on the arrow and set the « Mark to indicate historical past for » to All and choose Each to plot trails and marks.
You now have an animated map utilizing a KML file.
That was tremendous straightforward, proper? However pay attention to the restricted fields which might be obtainable in Tableau from the KML file. You solely have Geometry and the identify of the purpose to work with. There isn’t a straightforward solution to hyperlink this file up (be part of or mix) with one other file until the purpose names match up. We can also’t use generated Longitude and Latitude in calculations. If we had an inventory of the longitudes and latitudes together with a Level ID and Path Order in CSV we may append all form of extra knowledge or do customized calculations. To do that we are able to convert the KML file (or Shapefile or GeoJSON) to a CSV.
Changing Spatial Information
There are a selection of nice on-line conversion instrument that I discover very helpful for changing spatial information. The instruments beneath are free to make use of based mostly on day by day report limits.
KML to Shapefile
https://mygeodata.cloud/sitemap/conversionslist?style=converter&type=1
KML to Lat/Lon
https://mygeodata.cloud/converter/kml-to-csv
http://www.convertcsv.com/kml-to-csv.htm
Merely use one of many instruments to transform the KML file (or no matter spatial file format you have got). I used the KML to CSV converter which can output the latitude and longitude of the factors within the KML file as a CSV.
Now that it is a CSV file you would additionally append or be part of different knowledge, for instance, elevation, state, county, zip code, and so forth. You might additionally reverse geocode the latitiude and longitude for an handle. For instance, utilizing Geocod.io, I used to be in a position to rapidly append Deal with, Metropolis, State, Zip Code, County, Time Zone, Faculty District, FIPS and MSA simply utilizing the latitude and longitude within the CSV file.
When accomplished, you now have a CSV file that is able to import into Tableau.
Open a brand new knowledge supply in Tableau. Choose Textual content File and selected the brand new CSV.
Transfer Longitude to Columns.
Transfer Latitude to Rows.
Transfer Identify to particulars.
It is best to now see the factors of your customized map plotted as a map in tableau.
You’ll be able to add a Path Order to the file if wanted by splitting the Identify area that was created within the Google mapping instrument.
Proper-click on Identify, choose « Rework » after which « Cut up ». This can create a area for the trail order, for instance « Level 12 » turns into « 12 ».
Rename this area to Path Order
If you would like traces as a substitute of dots, then change the dropdown on the Marks Card to traces (or Polygon if desired).
Choose « Strains » from the dropdown field on the Marks Card.
Transfer Path Order to paths.
Take away Identify from particulars by dragging off the canvas or right-clicking and choosing take away. (you would additionally use Identify on paths on this case because it’s distinctive and sequenced so as)
It is best to now have the identical factors plotted as a line. Here is my working route as a line.
Since there’s a Identify and a Path Order, it is easy to create an animated map of the route with the factors.
On the Marks Card, transfer Path Order from « Path » as much as « Web page Filters ».
This can present play controls and we are able to now animate the working route. That is just like the approach I used for visualizing the Cincinnati trash truck routes here.
Including Factors to Map
If we wish to add factors to the mapping route then we are able to try this with a twin axis.
Duplicate Longitude on the Columns by holding he management key down and dragging Longitude subsequent to itself. You now have two marks playing cards.
Proper-click on the second Longitude tablet and choose twin axis (there isn’t a must synchronize the axis for maps).
Add Identify to the « Particulars » on the second Marks Card labeled Longitude.
Change the dropdown field to Circles on the second Marks Card labeled Longitude.
It is best to now have an animated map plotting the customized map route, with each traces and circles. I added a Mapbox Map layer as effectively.
As a ultimate step, we are able to hyperlink the longitude and latitude up with Google Streetview in order that we are able to see the route at every level. To do that, I’ll leverage the URL data from this blog post on How to Embed Google Maps in Tableau. Beneath is an instance of this system in motion.
Notice – you should use this similar Google Maps approach with the KML information by changing the Longitude and Latitude within the URL with the generated Longitude and Latitude of the Geometry area.
I hope you discover this data helpful. If in case you have any questions be at liberty to e mail me at Jeff@DataPlusScience.com
Jeffrey A. Shaffer
Comply with on Twitter @HighVizAbility