Keeping PostGIS up to date: Compiling from source and updating databases.

Although it is usually preferable to stick with stable releases of PostGIS for production databases, there are good reasons to use recent development versions for raster processing.

Compiling from source on Ubuntu is quick and painless using default settings, providing all the libraries are available.

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get -y install
sudo apt-get install libxml2-dev libgeos-dev 
sudo apt-get install libarmadillo-dev libpoppler-dev libepsilon-dev libexpat-dev liblzma-dev
tar xvzf postgis-2.2.0*tar.gz
cd postgis*dev
sudo make install

The loaders are compiled and just need installing.

cd postgis*dev*/loader
sudo make install
cd ..
cd ..
cd postgis*dev*/raster/loader
sudo make install

PLR can also be compiled from source.

cd plr-master
USE_PGXS=1 make
sudo USE_PGXS=1 make install

Now to update a data base into which PostGIS has been installed though the extension mechanism

ALTER EXTENSION postgis_topology UPDATE TO '2.2.0';

If this does not work, for example if you have a database that installed PostGIS using the older SQL route, then you can upgrade through the backup and restore mechanism.
For example, to update a database called “reddeam”.

sudo -u postgres pg_dump reddeam > reddeam.backup
dropdb reddeam
createdb reddeam
psql -d reddeam -c "CREATE EXTENSION postgis;"
psql -d reddeam -c "CREATE EXTENSION postgis_topology;"
sudo -u postgres psql reddeam<reddeam.backup

You may need to add support for legacy functions if you used them.

More advise is avalailable here.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s