I recently led a teaching day on Spatial Analytics for the rest of the dataschool. The first half of the day was dedicated to Alteryx practice and for the second half of the day we covered some of the spatial analytics topics relevant to Tableau. One of these is custom geocoding.

Tableau automatically recognises certain spatial fields. If you import a dataset with country names for instance, Tableau will automatically know where to place these if you are making a map. But Tableau might not have the spatial coordinates stored for smaller cities, and sometimes you might want to map something more specific, like the location of all of the stores in your business. You can teach Tableau to recognise these stores as a new geographical role and it can then automatically plot them.

When you want to use custom geocoding depends on what you want to do. I haven’t been able to find any definitive guidance yet. To map your stores in Tableau you will need a file with these stores and the associated latitudes and longitudes. If you have this data you can map these stores directly by simply plotting all the lat/longs and splitting them up by placing your ‘store’ field on detail (or disaggregating everything). With a tool like Alteryx it is an easy process to append these lat/longs to the store information you already have so that you have all the information in one file. In this case you might not want to bother with custom geocoding, which can negatively impact the size of your workbook and takes time to set up. However, if you have two separate files with this information and no easy way of connecting them, or if they are in two separate databases then custom geocoding might make your life easier.

For my teaching session we used London tube stations as an example.

  1. From https://www.doogal.co.uk/london_stations.php you can download a complete list of stations with their coordinates.
  2. Create a schema.ini file by opening windows Notepad and writing out the information about your file in the following format, making sure that your latitude and longitude are Double fields and that the column names are typed exactly
    1. [Londonstations.csv]
      ColNameHeader=True
      Format=CSVDelimited
      Col1=”Country” Text
      Col2=”Station” Text
      Col3=”Latitude” Double
      Col4=”Longitude” Double
  3. When you save this declare the file name to be ‘schema.ini’ and set the type to be ‘All Files’
  4. Place both of these files into a new folder containing just these two files.
  5. In Tableau, go to > Map > Geocoding > Import Custom Geocoding
  6. Select the button to the right with the three dots, which will allow you to navigate to your folder
  7. Note that the files themselves won’t show in this view, you will simply direct Tableau to the folder from which it will import everything
  8. Tableau will now take a little while to process this new information and import your custom geocoding. If there is an error message after this process make sure that your schema.ini file was formatted correctly. Also make sure that each of the records within your file is unique, custom geocoding will not work if you have the same station name in your file more than once.
  9. Now you can navigate to a field and select the option ‘geographic role’ and your new custom geocoding field should be listed. If you take a new file with Station data for instance, which does not have coordinates associated with it then Tableau will be able to match the stations as long as the names match.

Custom geocoding

Custom geocoding 2

Tube stops London Tableau

London tube stops coloured by zone