Building a US Census Tracts PostGIS Database

This article shows how you (yes, you!) can build your very own US Census Tracts PostGIS database. I had looked over the interwebs for some time under the false assumption that someone, somewhere would have already done this, but it seems not. So this article documents my process. I am running a mac, so some things could be done faster / smarter using other technology refinements, but I have tried to keep things pretty generic for ‘nix users. Windows people; you will find this process is pretty simple, I am sure you can replicate it using what you have available.

You will need:

PostGIS running (locally in my case), that means you should look at the PostGIS requirements for your machine.

That should get you the data you need, in the directory in which you reside. Now unzip it:

unzip *.zip

Step 2 – make data useful

Once that is complete, you should have a directory full of shapefiles. I found I have 56 shapefiles, check your too using:

ls *.shp | wc -l

but as the census bureau are the custodians I could not comment on if you will get exactly the same number or not. Now, we want to load up a database. Go to postgres and set up a database. I called mine censustract2012, make sure it is built using your PostGIS template, perhaps like this: