Monday, February 14, 2011


Brazil Part II

a partial list of administrative areas from Brazil. I found the shapefile for this from http://www.ibge.gov.br/. I then converted it using shp2text.exe. I then ran it through MS Access which allowed me to add a unique key for Tableau polygon paths. The list of states is partial simply to reduce the row count.

UPDATE: Some folks asked for more details on how this is achieved. I have tried to write it up a bit more. The details are below the visual. I really don't know why this is such a tedious process... but it is. Hopefully my additional notes below will help.





There are a few different ways to get a shapefile into Tableau as "polygon" data.


1.

Joe Mako has a great video located here:

http://goo.gl/DrNG6

2.

The "shp2text to ms access to tableau" method. Download all three of these files to a directory:

ftp://geoftp.ibge.gov.br/mapas/malhas_digitais/municipio_2005/E500/Proj_Geografica/ArcView_shp/Brasil/

Download shp2text.exe from here:

http://www.obviously.com/gis/shp2text/

from a prompt, run this command:

shp2text.exe --spreadsheet 55mu500gc.sph > output.tab

This outputs the contents to a tab delimited file called "output.tab"

Now import this file into MS ACCESS - when importing, tell MS ACCESS to add a "primary key" - you will use this new column in Tableau for the Tableau "path ID". Also, during the import, make sure that you tell MS ACCESS that "the first row contains field names".

Once the data is inside of MS ACCESS, you can now connect to it with Tableau, and follow the general instructions for polygons found here:

http://www.tableausoftware.com/support/knowledge-base/polygon-shaded-maps

3.

If you have ArcGIS, you can follow these instructions instead, as they will save you some time:

http://www.tableausoftware.com/community/support/kb/tableau-polygons-arcgis-shapefiles

4.

Field Names of importance, specific to the Brazilian data set:

X-Coordinate: this is the longitude, set this to "longitude" in Tableau
Y-Coordinate: this is the latitude, set this to "latitude" in Tableau
ID2: this is the MS Access generated primary key, you will want to use this on the "path" shelf in Tableau.

3 comments:

Jura said...

Hi Allan, how are you?

Great stuff you did, congratulations.

About the tips you did above, is just that or you did something more?
Would you like to give more ideas step by step how you did that workbook in Tableau?

Juracy from Brasil

Fadi Mohsen said...

Hi Allan, good job!
i need a little help!
Did you use shp2text.exe on top of windows or linux?
what was the command you used?
i tried to use this command on windows cmd:
shp2text.exe file.shp and also i used
shp2text.exe --spreadsheet file.shp
, but i couldn't find the result file?

Chris said...

Fadi, you need to write "shp2text.exe --spreadsheet file.shp > outputfilename.tab". I screwed up in the same way on a huge file.