Book Image

Learning QGIS 2.0

By : Anita Graser
Book Image

Learning QGIS 2.0

By: Anita Graser

Overview of this book

QGIS is a user friendly open source geographic information system (GIS) that runs on Linux, Unix, Mac OSX, and Windows. The popularity of open source geographic information systems and QGIS in particular has been growing rapidly over the last few years. More and more companies and institutions are adopting QGIS and even switching to QGIS as their main GIS. Learning QGIS 2.0 is a practical, hands-on guide that provides you with clear, step-by-step exercises that will help you to apply your GIS knowledge to QGIS. Containing a number of clear, practical exercises, this book will introduce you to working with QGIS, quickly and painlessly. If you want to take advantage of the wide range of functionalities that QGIS offers, then this is the book for you. This book takes you from installing and configuring QGIS, through handling spatial data to creating great maps. You will learn how to load and visualize existing spatial data and how to create data from scratch. You will perform common geoprocessing and spatial analysis tasks and automate them. We will cover how to achieve great cartographic output and print maps. You will learn everything you need to know to handle spatial data management, processing, and visualization tasks in QGIS.
Table of Contents (12 chapters)

Installing QGIS


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.

Installing on Windows

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).

Installing on Ubuntu

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