Location data can come in many forms and formats, but one of the most common formats is in separate fields containing latitude and longitude values. This data might reside in an Excel file, CSV or any other table of data. These values could represent anything: the position of a physical location, object, Wi-Fi hotspot, wildlife, or literally anything else on the planet.
For people trying to understand their location data and to see spatial patterns, Tableau is adding two spatial functions that will make analysing location data easier than ever. The spatial functions are called MakePoint and MakeLine. While their names are self-explanatory, permit me a few paragraphs to showcase what is now possible with maps in Tableau.
Use longitude/latitude fields in a spatial join to map police incidents using MakePoint
Let’s start with MakePoint, a function that will allow you to use latitude and longitude fields in a spatial join. Spatial joins allow you to use points and polygons to join datasets based on their spatial relationship, and MakePoint is the function that can... make points! Another way to think about this function is that it turns non-spatial data sources like text files and Excel tables into spatial data sources that allow you to spatially aggregate spatial data.
In this example, I am going to explore the city of San Francisco’s open data for crime incidents by neighbourhood. To get started, I visited data.sfgov.org and downloaded a neighbourhood shapefile as well as the latest incident report data as a CSV file. The incident dataset includes latitude and longitude fields, and a number of other categories like Police District or Incident Type. My questions are which neighbourhood has the most reported incidents and what neighbourhoods have the highest risk of theft. Look at how easy it is to answer these questions now. After connecting to the shapefile, I can add a connect to the CSV and use MakePoint in a join calculation to allow me to use Intersects to complete the spatial join.
With the data joined, I can use Number of Records to visualise which neighbourhood has the most crime incidents and use a filter to answer my question about theft.
Connecting origins and destinations for flight routes using MakeLine
After I create the calculated field, I can simply drop that field on to the canvas and we’re ready for takeoff. MakeLine generates geodesic lines, which will display as curved when connecting locations that are far apart on the earth. When working with data at a local/city scale, like pick-up and drop-off locations for a bicycle-share, the lines will appear straight.
Get more out of your location data to reveal hidden spatial patterns. Spatial calculations make geospatial analysis simple, and remove the need for pre-processing and shaping of data. Spatial functions represent another building block capability in Tableau and we can’t wait to see what you build with it. Members of the Tableau community are already sharing some of their examples. Marc Reid build an interactive dashboard to look at flights from different origin cities.
Jeffery Shaffer takes some community inspiration to build an exploration of ride-share data using set actions, vector maps and spatial calculations.
I want to encourage everyone to stay tuned in for the 2019.3 beta, as we expect to release more spatial functions for early testing. Until then, go forth and make beautiful maps!