Richard Leeke's TabGeoHack is a fantastically useful addition to Tableau, but frustratingly for us Mac users it requires Windows. I didn't want to have to use Tableau through a virtual machine, so I figured out how to use TabGeoHack in a virtual machine, but have it import geocoding to Tableau that is installed on the host Mac. This means I only need the VM to change geocoding, not for day-to-day Tableau work. Unsurprisingly, Tableau Desktop is noticeably faster on the host machine than in the VM.
You will need:
- VirtualBox, which is a free virtual machine host. This can probably be achieved with other products, but my instructions assume VirtualBox. If you get this working using a different virtualiser please post about it below - this will be useful to others.
- A copy of Windows. I am using Windows 7. I would expect the same instructions to work in newer versions, but haven't tested them. If you get this working with a different version of Windows, please also reply!
- Install VirtualBox
- Set up a VM running Windows. From experience: VirtualBox lets you choose either a fixed hard drive size or a mode that lets the drive grow as needed. You can't change this setting later, and if you choose a fixed size it needs to be > 20GB. I gave mine 25, which is enough that I can also run Alteryx in it.
- Set up two shared folders, both with Access set to "Full" and Auto-mount enabled. One should go to the Tableau repository on your Mac, the other to a folder where you'll put TabGeoHack and data files. Here's how I have mine:
path "/Users/eldan/Dropbox/TabGeoHack" name "TabGeoHack"
path "/Users/eldan/Documents/My Tableau Repository" name "My_Tableau_Repository"
What this does is to make these available as mapped network drives when you boot up Windows. "path" is where the folder exists on the host Mac; "name" is how we'll refer to it from within the Windows VM. Note that VirtualBox assigns drive letters to these in alphabetical order, starting from E:, so in the setup I'm using My_Tableau_Repository is E: and TabGeoHack is F:
- Save TabGeoHack on your Mac, inside the first folder that you shared with the VM. (i.e. my copy is in /Users/eldan/Dropbox/TabGeoHack )
- Install GDAL in the Windows virtual machine. Mine is at C:\Users\eldan\Desktop\gdal
- Open tabgeohack.yml on the Mac, and edit it based on the following, with paths adapted to your system (and no indentation):
# path of Tableau repository
# GDAL installation path
- In the .yml file that defines the geocoding you'll be importing (start with the included geocoding_template.yml if you're starting from scratch), reference the shapefile and output directories in ways that will work from within the VM. The important things here are that \\vboxsrv\ connects to all shared folders, the name after that is the name I mapped the shared folder as in step 3, and what's after that is subdirectories I created within /Users/eldan/Dropbox/TabGeoHack/
# location of input spatial data files
# location of various generated files
Normal use (with new shapefiles):
- Prepare shapefile[s] (platform independent)
- Drop them into whatever directory you've indicated as shape_file_dir
- Edit the geocoding...yml file to tell TabGeoHack about the new shapefile[s]
- In the Windows VM: open a command line and go to the drive letter for the TabGeoHack mapped network drive (F: in my setup)
- In the Windows VM: run tabgeohack --roles etc
- Back in Mac OS: open Tableau and import custom geocoding as normal. NB: in my setup I usually get warnings about UNI_ID_Features.csv not containing Latitude & Longitude columns, and UNI_ID_points.csv not containing a unique column - these are safe to ignore.
- Close Tableau
- In the Windows VM: run tabgeohack --shapes etc
- Back in Mac OS: Hooray! Your geocoding is now loaded.
Normal use (with previously loaded shapefiles):
I have not managed to get --assign to work in this setup. However, I have had good results with making separate .yml files and subdirectories for different countries' geocoding, and using --activate to switch between them. I just have to close Tableau on the Mac, call tabgeohack --activate countryiwant.yml from the Windows VM, and then reopen Tableau on the Mac.