Installation of PostGIS on Debian 6.0

Categories: Fri software , Nørderier , Udvikling

25. marts, 2011

This is as much a note-to-self as it is a blog post.; Now, for the third time, I have had to install PostGIS, and each time I do this, I forget a minor detail. So now I have decided to add this. You are of course welcome to comment with any corrections, as I could have forgot somthing this time around, or been doing something wrong the whole time.

The installation of the software it self is handled by ordinary apt-magic:

aptitude install postgresql-8.4-postgis

The next step is to create a database, which have all the necessary support functions. This is to be done as the postgres user, as setting up PostgreSQL users and permissions are out of the scope of this.

sudo -u postgres createdb geo_db
sudo -u postgres createlang plpgsql geo_db
sudo -u postgres psql -d geo_db -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d geo_db -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -d geo_db -f /usr/share/postgresql/8.4/contrib/postgis_comments.sql

And now, the database is ready, except for one minor detail. I couldn't find my geografic reference of choice, ETRS89 / UTM zone 32, also known as EPSG::25832. This procedure can be repeated for other not-included reference systems.

At, different spatial references can be found, and each entry contains a ready-made PostGIS INSERT statement:

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 925832, 'epsg', 25832, '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs ', 'PROJCS["ETRS89 / UTM zone 32N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],AUTHORITY["EPSG","25832"],AXIS["Easting",EAST],AXIS["Northing",NORTH]]');

And, voi-la!, the database is now ready for geo-goodness!

Correction: Actually, it seems that PostGIS in fact does include ETRS89 / UTM zone 32N as a part of the standard package, but at least now, I have figured out how to add a reference.

dansk english