giovedì 27 settembre 2012

Setup PostGIS 2.0.1 and PostgreSQL 9.1 on Ubuntu 12.04

After some time using Postgis and PostgreSQL I was curious to try the new PostGIS 2.0 discovering new features.
Thus I try to update my Ubuntu 12.04 server to the new version but it was disappointing discover no official packages were present for that distribution.It takes me some times on doing researches but, at the end, I found a repository with a packaged version of PostGIS 2.0, other than the updated libraries necessary.
So do the following steps:

$sudo apt-get install python-software-properties
$sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
$sudo apt-get install postgis

Now, using the psql command line, we can connect to the Postgresql server:

$ sudo -s -u postgres
postgres$ psql
psql  (9.1.5)
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
postgres$

Ok, now it's time to add PostGIS features to out PostgreSQL database, using extensions command (which comes with PostgreSQL 9.1):

Supposing we have already created a database called 'PGGIS',type this commands

PGGIS=# CREATE EXTENSION postgis;
CREATE EXTENSION
PGGIS=#

Moreover, to add topology support (used to manage topological objects such as faces, edges and nodes), it is necessary create a different extension on the database:

PGGIS=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
PGGIS=#


Ok, that's all folks. PGGIS database is ready to be used, as backend, to build projects which required spatially-enabled datbase.

P.S. Pay attention not to add the

ppa:sharpie/postgis-stable  

repository and don't try to install the 

postgresql-9.1-postgis2 

package, otherwise a conflict will be raised, because the library 

/usr/lib/postgresql/9.1/lib/rtpostgis-2.0.so 

is already contained on the postgresql-9.1-postgis package

2 commenti:

Unknown ha detto...

Thank you for this great guide, hope you can help me with my error. When trying to create the postgis extension I get:

ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control": File or directory not found

The file is nowhere on my filesystem, tried to do it with postgis 1.5 and 2.0, same error.
Any advice?

Unknown ha detto...

finally made it after i built postgis myself from source following this guide.

http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204