Linfiniti Geo Blog

GIS for Open Source People

Browsing Posts published on November 28, 2009

A lot of people are scared off from compiling QGIS on Ubuntu thinking the process is too complicated. Actually its pretty easy and you can do it in just a few steps. This weekend I am updating my desktop PC from Ubuntu Jaunty 9.4 to Ubuntu Karmic 9.10 by way of a clean OS install, so I thought I would document the steps needed to get a working QGIS build environment set up in the hopes that others might like to try. Building QGIS from source lets you be an early adopter, trying out the many new cool features that have made their way into subversion (our source code repository), but that are not yet in our mainstream releases.

Installing Dependencies the easy way

Firstly add the ubuntu-gis repository to you apt sources list:

sudo su -c "echo 'deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu karmic main' >> /etc/apt/sources.list"
sudo su -c "echo 'deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu karmic main' >> /etc/apt/sources.list"

Now update your package database:

sudo apt-get update

Now tell Ubuntu to install all build dependencies for QGIS:

sudo apt-get build-dep qgis

Now say ‘Y’ at the prompt and if you are in South Africa wait a few hours while the bits crawl across the wires and deplete your bank account. On my clean system it downloaded around 124mb of packages – pretty much everything you need to build QGIS including the compiler environment, the dependent libraries and their header files etc.

Building QGIS

Building QGIS is well documented in our INSTALL document that comes included but here is the quick version:

First install subversion and cmake console, cmake qt4 gui’s and a few other goodies:

sudo apt-get install subversion cmake-curses-gui \
cmake-qt-gui gdal-bin libgdal1-1.6.0-grass python-gdal

Now we can go on to build QGIS. I am telling CMAKE to install my hand built copy into my home directory (under a subdirectory called apps) to that it does not conflict with with any other copies of QGIS that may be on the system – although you may run into some issues with having a system level install of QIGS and a local copy unless you have tightly managed your library search paths.

cd
mkdir -p dev/cpp
cd dev/cpp
svn co https://svn.osgeo.org/qgis/trunk/qgis
cd qgis
mkdir build
cd build
ccmake -DCMAKE_INSTALL_PREFIX=${HOME}/apps \
-DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=True ..

Set your library search path

Note This section was added in an update on 31 Nov 2009

If you want the grass plugin to load in QGIS, you also need to ensure your library path is updated. I do it system wide. First edit /etc/ld.so.conf as root and add this line:

/usr/lib64/grass64/lib/

Now do:

sudo ldconfig

Running QGIS

I add a launcher to my Gnome panel that points to /home/timlinx/apps/bin/qgis. After that your hand build QGIS will be a simple click away. QGIS source code is always under development and we try at all times to ensure the code in SVN will build cleanly. If you want to get the latest updates, simply do:

cd
cd dev/cpp/qgis
svn update
cd build
make install

Assuming you got no error messages during the build, you QGIS launcher icon should now launch the latest build.

I’ve posted this before on my old blog so this is a repeat for those looking to get going with PostGIS in a hurry. This procedure should work on Ubuntu Jaunty or Ubuntu Karmic and possibly earlier versions.

sudo apt-get install postgresql-8.3-postgis
sudo su - postgres
createuser -s -d -r -l -P -E timlinux
createdb gis
createlang plpgsql gis
psql gis < /usr/share/postgresql-8.3-postgis/lwpostgis.sql
psql gis < /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql

Having done that, you should be able to connect to the database by creating a new postgis connection in QGIS. After that you can start to load data into your spatial database using SPIT (QGIS plugin to import shapefiles into QGIS) or the shp2psql command line tool.

We will be going into feature freeze for QGIS 1.4 soon. There has been so much work going on in QGIS for this release, I thought I would take a moment to show the world what you might expect rendering-wise from the upcoming release.

Symbology-ng

The symbology-ng merge has brought in many improvements to the quality of cartography we can do in QGIS. Take a look at this first screenshot (click on it to get the full image):

viewlayout_in_qgis1.4

In the previous incarnations of QGIS, in order to make this map I would have loaded the polygon layer for country boundaries three times. Each instance would have been given a border with a different thickness, so producing the black, grey, blue outline effect you can see in the image. With the new symbology infrastructure, one can now create a custome polygon symbol type that overpaints the lines numerous times. In the screenshot below you can see how the symbology for my countries was constructed.

layerproperties-ng

The key here is the concept of ‘symbol layers’. Each symbol layer can have its own fill, outline width and colour etc. They are drawn from bottom to top when the feature is rendered. The ‘symbol levels’ button you can see in the background window in the above screenshot lets you dictate if the symbol layers are drawn per feature or for all the features in the view extent. If layers are drawn per feature, then you get something like the screenie below. If you draw symbol layers for all features in the view extent then the bottom most symbol layer is drawn for all features, then the next layer up and so on. This gives you an effect as shown in my first screenshot above.

nolayerlevels

Labelling

I’ve blogged before about the new labelling engine provided as a plugin for the upcoming 1.4 release. It will be a plugin because it does not yet support data driven label placement and a few other things that we need before it can become the default labelling engine.

viewlayout2_in_qgis1.4

In the screenshot above, you can see how neatly the engine places the town labels – none of them overlap and the result is quite a readable, easy on the eye map.

Map Composer

Another area of QGIS that has been receiving a lot of attention is the map composer. It now supports rotating maps, annotations with arrows and shapes and many other improvements. Unfortunately, the new labelling engine is not yet supported in the map composer, and the new symbology framework does not produce a proper legend in composer. We will see if and which of these limitations will be addressed for the 1.4 release. In the screenie below you can see some of the new features at work.

maplayouts_in_qgis1.4