Although the official documentation recommends loading legacy.sql only "if really necessary", we have found that it is indeed required for installing Tiger Geocoder and running the OGC tests suite. It is also necessary to restore data from an old database. Run uninstall_legacy.sql later to remove the deprecated functions.

Create a new database with PostGIS support with:

$ createdb -T template_postgis geocoder

If you prefer to use the psql console:

CREATE DATABASE geocoder TEMPLATE template_postgis;

How can I get PostgreSQL with PostGIS support?

Depending on the Bitnami stack you have installed, PostgreSQL and PostGIS might already be included. Refer to this page for more information and installation instructions.

How can I install Tiger Geocoder?

NOTE: This guide is for PostgreSQL 9.1+.

Tiger Geocoder is a plpgsql-based fully-functional geocoder that can process an arbitrary address string and, using normalized TIGER census data, produce a point geometry and rating reflecting the location of the given address and likeliness of the location.

To install it, follow these steps:

Navigate to the /opt/bitnami/postgresql/share/contrib/postgis-2.0/extras/tiger_geocoder/tiger_2010/ directory.

Edit the create_geocode.sh script and set the PGPASSWORD and THEDB parameters. In this example, the database name will be geocoder (the default value) so it is not necessary to modify the THEDB parameter. Set the PGPASSWORD parameter to your database password.

In the same file, uncomment the line below if it is not already uncommented:

Edit the tiger_loader.sql file and set the PGPASSWORD and PGDATABASE parameters with the same values as in the create_geocoder.sh file. You may need to modify the lines containing export PGPASSWORD and export PGDATABASE.

Edit other parameters in the files, such as PGPORT, PGHOST, PGUSER, PSQL_CMD and PGBIN, as needed.

Edit the create_geocoder.sh file and comment out the line which refers to fuzzystrmatch.sql and uncomment the line containing CREATE EXTENSION fuzzystrmatch.

Create an example database with PostGIS support:

$ createdb -T template_postgis geocoder

Create the necessary schema:

$ ./create_geocode.sh

This will create the tiger schema in your database and make it part of your database search_path. To verify this, run the following command:

How can I load Tiger data in my database?

After installing Tiger Geocoder, load data from the census website into your database. The easiest way to do this is to use the loader_generate_script() function and create a script that will download data from the census website, extract it and load it into the example database. This example will load the data for the state of Rhode Island (RI).

Edit this file and set the PGPASSWORD parameter to reflect the correct database password.

Remove the first and last lines of the script. These are not Bash commands but output of the SQL command executed previously). Notice that the script uses the /gisdata directory to store the data downloaded from the census website. You can change this location if you wish.

Run these commands to obtain and load the data. Note that the wget and unzip commands should be installed for this to work.

If necessary, replace the account username bitnami with the correct username for the user running these commands.

How can I check that everything works?

To checking that everything works, run the OGC Test suite, as these scripts use the PostGIS functions. Using this test suite also helps verify that the Simple Features for SQL specification from the Open Geospatial Consortium (OGC) are implemented.

Browse to the /opt/bitnami/postgresql/data/pg_hba.conf/postgresql/share/contrib/postgis-2.0/extras/ogc_test_suite directory and run these commands: