In this chapter, we will install and configure the QGIS geographic information system. We will also get to know the user interface and how to customize it. By the end of this chapter, you will have QGIS running on your machine and be ready to start with the tutorials.
QGIS runs on Windows, various Linux distributions, Unix, Mac OS X, and Android. Also, the QGIS Project provides ready-to-use packages as well as instructions for building from source code on download.qgis.org. We will cover how to install QGIS on the two most common systems, Windows and Ubuntu, as well as how to avoid the most common pitfalls.
Like many other open source projects, QGIS offers you a choice between a stable release version and the cutting-edge developer version, also called master. QGIS master will contain the latest and greatest developments, but be warned that on some days, it might not work as reliably as you are used to. For the tutorials in this book, we will be using the QGIS 2.0 release.
On Windows, we have two different options to install QGIS: standalone installer and OSGeo4W installer. The standalone installer is one big download (approximately of 130 MB), which contains a QGIS release and the Geographic Resources Analysis Support System (GRASS) GIS in one package. The OSGeo4W installer is a small, flexible installation tool that makes it possible to download and install QGIS and many more OSGeo tools with all their dependencies. The main advantage of this over the standalone installer is that it makes updating QGIS and its dependencies very easy. You can always have access to both the current release and the developer version, if you chose so, but of course, you are never forced to update. That's why I recommend using OSGeo4W. The OSGeo4W installer can be downloaded from osgeo4w.osgeo.org (or directly from download.osgeo.org/osgeo4w/osgeo4w-setup.exe). Download it and keep it! In the future, whenever you want to change or update your system, just run it again.
Tip
Regardless of the installer you choose, make sure to avoid special characters in the installation path, as they can cause problems later on, for example, during plugin installation.
When the OSGeo4W installer starts, we get to choose between the Express Desktop, Express Web-GIS, and Advanced installation. To install the QGIS release version, we can simply select the Express Desktop option and the next dialog will list the available desktop applications such as QGIS, uDig, and GRASS GIS. We simply select QGIS, click on Next and download and installation will start automatically. When the installation has finished, there will be desktop shortcuts and start menu entries for OSGeo4W and QGIS.
If we want to install QGIS master, we need to go through the Advanced installation. This installation path offers many options such as Download without installing and Install from Local Directory, which can be used to download all the necessary packages on one machine to later install them on machines without Internet access. It's usually not necessary to change the default settings, but if your machine is, for example, hidden behind a proxy, you will be able to specify it here. After the installer fetches the latest package information from OSGeo's servers, we get to pick the packages for installation. QGIS master is listed in the desktop category as qgis-dev. To select it for installation, click on the text that reads Skip and it will change and display the version number. The installer will automatically select all the necessary dependencies (such as GDAL, SAGA, OTB, and GRASS), so we don't have to worry about that. After clicking on Next, the download and installation starts automatically just like in the Express version. The dialog will look like the following screenshot:

If you try to run QGIS and get a pop up saying
The procedure entry point <some-name> could not
be located in the dynamic link library <dll-name>.dll, you are facing a common issue on Windows systems: a DLL conflict. They are easy to fix; just copy the DLL file mentioned in the error message from C:\OSGeo4W\bin\
to C:\OSGeo4W\apps\qgis\bin\
(adjust paths if necessary).
On Ubuntu, the QGIS project provides packages for both the release and developer version. Be aware, though, that you can only install one version at a time. The packages are not listed in the default Ubuntu repositories. Therefore, we have to add the appropriate repositories to Ubuntu's sources list, which you can find in /etc/apt/sources.list
. You can open the file with any text editor.
Make sure that you have super user rights, as you need them to save your edits. One option is to use gedit, which is installed on Ubuntu by default. To edit the sources.list
file, use the following command:
sudo gedit /etc/apt/sources.list
Make sure to add only one of the following four package source options to avoid conflicts due to incompatible packages. The specific lines you have to add to the source list depend on your Ubuntu version.
The first and default option is to install the current release version. To install the QGIS release on Precise Penguin, add the following lines to your file:
deb http://qgis.org/debian precise main deb-src http://qgis.org/debian precise main
If necessary, replace precise
with raring
, oneiric
, natty
, or lucid
to fit your system. For an updated list of supported Ubuntu versions, check download.qgis.org.
The second option is to install the QGIS master, which is currently available for precise
, quantal
, and raring
. Add the following lines to your file:
deb http://qgis.org/debian-nightly precise main deb-src http://qgis.org/debian-nightly precise main
Tip
The preceding versions depend on other packages such as GDAL and proj4, which are available in the Ubuntu repositories. It is worth mentioning that these packages are often quite old.
Therefore, the third option is to install the QGIS release version with updated dependencies, which are provided by the ubuntugis
repository. Add the following lines to your file:
deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main
The fourth option is QGIS master with updated dependencies. Add the following lines to your file:
deb http://qgis.org/ubuntugis-nightly precise main deb-src http://qgis.org/ubuntugis-nightly precise main deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main
After choosing the repository, we add the qgis.org
repository public key to our apt
keyring. This will avoid warnings you might otherwise get when installing from a non-default repository. Run the following command in the terminal:
gpg --keyserver keyserver.ubuntu.com --recv 997D3880 gpg --export --armor 997D3880 | sudo apt-key add –
Note
The key information might have changed since this book went into print. Please refer to hub.qgis.org/projects/quantum-gis/wiki/Download#26-Ubuntu for the latest updates.
Finally, to install QGIS, run the following commands:
sudo apt-get update sudo apt-get install qgis python-qgis qgis-plugin-grass
By default, QGIS will use the operating system's default language. To follow the tutorials in this book, it is advisable to change the language to English by navigating to Settings | Options | Locale. On the first run, the toolbars are arranged in two rows and depending on your screen resolution, this can hide many buttons. To be able to work efficiently, I therefore suggest arranging the toolbars. I like to put some toolbars to the left and right screen borders to save vertical screen estate—especially on wide-screen displays.
Additionally, we activate the file browser by navigating to View | Panels | Browser. It will provide us quick access to our spatial data. In the end, your screen should look similar to the following screenshot:

Next, we activate some must-have plugins by navigating to Plugins | Manage and Install Plugins. Plugins are activated by ticking the checkbox beside their name. To begin with, I recommend the following:
Coordinate Capture: This plugin is useful for picking coordinates in the map
fTools: This plugin offers vector analysis and management tools
GdalTools: This plugin offers raster analysis and management tools
Processing: This plugin provides access to many useful raster and vector analysis tools as well as a model builder for task automation
To make it easier to find specific plugins, we can filter the list of plugins using the Search input field at the top of the window, which you can see in the following screenshot:

Now that we have set up QGIS, let's get accustomed to the interface! The biggest area is reserved for the map. To the left of the map, there are the Layers and the Browser panels. Below the map, we find important information such as (from left to right), current map coordinates, map scale, and the (currently inactive) project coordinate reference system (CRS).
Next, there are multiple toolbars to explore. If you arranged them as shown in the previous section, you'll find the following toolbars in the top row:
File: This toolbar contains tools to create, open, save, and print projects
Manage Layers: This toolbar contains tools to add layers from vector or raster files, databases, web services, text files, or create new layers
Database: Currently, this toolbar only contains DB Manager, but other database-related tools will appear here when they are installed
The following screenshot shows what the preceding toolbars look like:

The second row of toolbars contains the following:
Attributes: These tools are used to identify, select, open attribute tables, measure, and so on
Label: These tools are used to add, configure, and modify labels
Vector: This is currently empty, but will be filled by additional Python plugins
Web: This is currently empty, but will be filled by additional Python plugins
The following screenshot shows what the preceding toolbars look like:

On the left screen border, we put the following:
The following screenshot shows what the preceding toolbars look like:

Finally, on the right screen border, we find the following:
The following screenshot shows what the preceding toolbars look like:

Tip
All digitizing tools are currently inactive. They will only turn active once we start editing a vector layer.
Toolbars and panels can be activated and deactivated via the View menu's Panels and Toolbars entries as well as by right-clicking on a menu or toolbar, which opens a context menu with all available toolbars and panels. All toolbar tools can also be accessed via the menu. If you deactivate the Manage Layers toolbar, for example, you will still be able to add layers using the Layer menu.
QGIS is highly customizable. You can increase your productivity by assigning shortcuts to the tools you use regularly by navigating to Settings | Configure shortcuts. Similarly, if you find that you never use a certain toolbar button or menu entry, you can hide it by navigating to Settings | Customization. For example, if you don't have access to an Oracle Spatial database, you might want to hide the associated buttons to remove clutter and save screen estate as shown in the following screenshot:
