User Tools

Site Tools



PostGIS is a PostgreSQL extension for geo spatial searches and processing.


Install PostgreSQL from your normal package management system. Also install the postgis extension, postgis or postgresql-9.1-postgis (the version may vary).

Crunchbang 11 waldorf based on Debian 7 “Wheezy” comes with PostgreSQL version 9.1 which is fine. But the PostGIS extension is 1.5 (2.x is current). So we have to look for documentation for PostGIS 1.5, PostGIS - Create a spatially-enabled database.

The first step in creating a PostGIS database is to create a simple PostgreSQL database.

createdb [yourdatabase]

Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command

createlang plpgsql [yourdatabase]

Now load the PostGIS object and function definitions into your database by loading the postgis.sql definitions file (located in [prefix]/share/contrib as specified during the configuration step).

psql -d [yourdatabase] -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql

For a complete set of EPSG coordinate system definition identifiers, you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table. This will permit you to perform ST_Transform() operations on geometries.


If you wish to add comments to the PostGIS functions, the final step is to load the postgis_comments.sql into your spatial database. The comments can be viewed by simply typing \dd [function_name] from a psql terminal window.


PostGIS - 2.5 Create a spatially-enabled database

If you get the error geometry type does not exist then you should check that you run the SQL scripts not with your common database user but with a superuser. At the start of the script you may see an error message like keine Berechtigung für Sprache C which translates to something like no auth for language C. Run the script with the postgres user: su - postgres.

For a complete installation manual see the PostGIS wiki page:

The file 900913.sql can be found on debian under /usr/share/osm2pgsql.

postgis.txt · Last modified: 2014/07/11 09:55 by mihael