Could someone write a brief albeit dumbed down idiot's guide to installing postgis and loading national Tiger data on ubuntu? I've tried a few guides, namely, http://wiki.bitnami.com/@api/deki/pages/302/pdf, but I'm not having much luck. I apologize for the open ended nature of this question.
Answer
Since you have PostGIS 2.1.1 you're ahead of the game. Make sure you have wget installed, it is what will download the data from the Census FTP site.
Create a gisdata directory with:
sudo mkdir /gisdata
Use chown and chgrp commands to change the ownership and group of /gisdata so that your normal user can read and write to /gisdata.
Start psql and connect to your database. Once in psql use
\a
and
\t
so that the results of the query are formatted correctly.
I forgot this part initially! Before you can use the loader script you need to do some house cleaning. First thing is to make sure the tiger schema is in your search path. Next up check the values in tiger.loader_platform and tiger.loader_variables. These two tables control variables for the loader script like your username and password. I usually just edit them in PGAdmin. Next up you'll need to run a script that populates lookup tables and other bits of background goodness the geocoder will need. First set an output file:
\o nation_generator.sh
then run:
SELECT loader_generate_nation_script('sh');
Then exit psql and run the file:
sh ./nation_generator.sh
Then hop back into psql and type:
\o loader_script.sh
to output the results of the query to a textfile called loader_script.sql. Then execute the function that generates the loader script:
SELECT loader_generate_script(ARRAY['DC','RI'], 'sh');
This is the query whose output will be redirected to loader_script.sql. Replace 'DC' and 'RI' with the two letter abbreviations of the states you want to download.
Exit out of psql and run the script with this command:
sh ./loader_script.sh
This will download the files for the state(s) you select, unzip them, and import the data into your PostGIS database.
No comments:
Post a Comment