Loading polygons from a Shapefile (.shp) into Tableau has never been easier— even if you don’t have previous GIS experience or the budget to buy GIS software.
I found a GIS software that can do the task in just a few minutes. It's called QGIS and you can download it here.
For this tutorial, I am going to use the Cartographic Boundary Shapefiles – Counties from The United States Census Bureau website.
Extract the files and name it US Counties.
Once you have finished installing QGIS, open QGIS Desktop and select Plugins > Manage and Install Plugins.
Search for mmqgis and install it.
Now open QGIS Desktop and select Add Vector Layer.
Select Directory under Source type. Under Source, browse to and select the folder we extracted previously (US Counties), or the folder that contains your Shapefiles. Click Open.
QGIS will plot all the polygons in the Shapefile.
Note: you can toggle the edit button and delete all Counties you do not want. In this example, I kept only the counties on the Lower 48 States. Be careful if you choose to use this option, as it will permanently change your Shapefiles.
Go to Vector > Geometry Tools > Singleparts to Multipart...
Save it on a new location. For this case, create a folder in US Counties called Singleparts. Name the new file Single Polygons. One you are done, click OK.
Note: To avoid confusion on later steps, go to the Layers Panel in the bottom left corner and remove the polygon from QGIS that we where using thus far.
We are almost done with our work on QGIS. Now, go to MMGIS > Import / Export > Geometry to CSV File.
Select a new location and rename the files you are about to save. IMPORTANT: on Line Terminator, select LF. Click OK when you are done.
That's it for QGIS. If you followed all the steps above, including the name convention I used during the Geometry Export, you should have two .csv files: one called Nodes and another called Attributes. Save both of these files in the same location.
Open the Nodes file in Excel, add a new column called Path, and create a sequence of numbers from one to however many lines you have (if you don't know how to do this fast on Excel, follow the instructions in this short video). Save the file when you are done and close it.
Note: if you have more than 1 million rows of data, you will not be able to open the entire file on Excel. If that is the case, open the file in a text editor (like Notepad), break the files into smaller ones and open each of them on Excel. For each file, the sequence should start from the highest number on the previous file. Example: you have two files, one with 652,345 rows and another with 432,282 rows. You will number the Path column on the first file from 1 to 652,345 and on the second one from 652,346 to 1,084,627. After that, save the files and open them again in a text editor. Copy and paste the rows in the second file under the last row in the first file. Save the document and continue to the next step.
Open Tableau. Go to Connect > Text File. Browse to the folder containing the Nodes file and open it.
If you saved the Attributes file in the same location, you should be able to simply drag-and-drop it to the right of the Nodes file.
On the data preview, make sure that shapeid (Attributes) and Shapeid (Nodes) are both listed as a string.
Note: don't forget to do this step for both shapeids.
Also, give a geographic role to the fields X and Y: X is Longitude and Y is Latitude.
Note: do this step again for Y, but this time set it to Latitude.
Once this setup is done, look at the join and make sure you have an Inner Join using the Shapeid fields. Click on Sheet 1.
From the Measures window, drag Shapeid (Nodes) and Path to the Dimensions window.
On dimensions, double-click X and Y. Change the Marks type to Polygon.
From Dimensions, drag Shapeid to Detail. Drag Path to Path.
Your polygon is ready. Add a border to easily visualize your shapes.
Voilà! You have a beautiful set of polygons ready to use with Tableau. Use data blend to connect your own data in this visualization. Feel free to change the background maps and use any other map functionality.