How to create PostGIS database on PostGRESQL (case of Ubuntu)

I like to use PostGIS for my GIS work. Creating a GIS database inside PostGRESQL is not straigth forward. I mean just a couple of lines but I do it by hand. My problem is Ubuntu rep installations do not match to the documentation installations. Therefore, I wanted to take a note to myself in this post how do I do it; so I can use it in the future. Maybe you find helpful too.


Below you will find what is suggested by the documentation and my addition (in bold). It works for me this way !

$ createdb -h localhost -U postgres -w
$ createlang -h localhost -U postgres -w plpgsql
$ psql -h localhost -U postgres -w -d -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
$ psql -h localhost -U postgres -w -d -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql
$ psql -h localhost -U postgres -w -d -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

Post a comment