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 to build from the source code at http://download.qgis.org. We will cover how to install QGIS on two systems: Windows and Ubuntu, as well as how to avoid the most common pitfalls.
Further installation instructions for other supported operating systems are available at http://www.qgis.org/en/site/forusers/alldownloads.html.
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 or testing. QGIS master/testing will contain the latest and greatest developments, but be warned that on some days, it might not work as reliably as you want it to. For the tutorials in this book, we will use the QGIS 2.6 stable release.
On Windows, we have two different options to install QGIS: the standalone installer and the OSGeo4W installer. The standalone installer is one big file to download (approximately 260 MB for the 64-bit version and 320 MB for the 32-bit version); it 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 and the developer versions, if you chose to, but of course, you are never forced to update. That is why I recommend that you use OSGeo4W. You can download the 32-bit and 63-bit OSGeo4W installers from http://osgeo4w.osgeo.org (or directly from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe for the 32-bit version or http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe if you have a 64-bit version of Windows). Download the version that matches your operating system and keep it! In the future, whenever you want to change or update your system, just run it again.
Regardless of the installer you choose, make sure that you avoid special characters such as German umlauts or letters from alphabets other than the default Latin ones 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 installations. To install the QGIS release version, we can simply select the Express Desktop option, and the next dialog box will list the available desktop applications, such as QGIS, uDig, and GRASS GIS. We can simply select QGIS, click on Next, and the download and installation will start automatically. When the installation is finished, there will be desktop shortcuts and start-menu entries for OSGeo4W and QGIS.
If we want to install QGIS master/testing, 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/testing 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 this. 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 that says, The procedure entry point <some-name> could not be located in the dynamic link library <dll-name>.dll, it means that you are facing a common issue on Windows systems: a DLL conflict. This error is easy to fix; just copy the DLL file mentioned in the error message from
C:\OSGeo4W\apps\qgis\bin\ (adjust the paths if necessary).
On Ubuntu, the QGIS project provides packages for both the release and developer versions. At the time of writing this book, the Ubuntu versions Precise, Saucy, and Trusty, are supported, but you can find the latest information at http://qgis.org/en/site/forusers/alldownloads.html#ubuntu. 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 source list, which you can find at
/etc/apt/sources.list. You can open the file with any text editor.
Make sure that you have superuser 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 that you add only one of the following four package-source options to avoid conflicts due to incompatible packages. The specific lines that you have to add to the source list depend on your Ubuntu version.
The first option, which is also the default one, is to install the current version. To install the QGIS release on Trusty Tahr, add the following lines to your file:
deb http://qgis.org/debian trusty main deb-src http://qgis.org/debian trusty main
If necessary, replace
preciseto fit your system. For an updated list of supported Ubuntu versions, visit http://download.qgis.org.
The second option is to install the QGIS master, which is currently available for
precise. Add the following lines to your file:
deb http://qgis.org/debian-nightly trusty main deb-src http://qgis.org/debian-nightly trusty main
deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu trusty main deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu trusty main
The fourth option is the QGIS master with updated dependencies. Add the following lines to your file:
deb http://qgis.org/ubuntugis-nightly trusty main deb-src http://qgis.org/ubuntugis-nightly trusty main deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu trusty main
After choosing the repository, we will add the
qgis.org repository's public key to our
apt keyring. This will avoid warnings that you might otherwise get when installing from a non-default repository. Run the following command in the terminal:
gpg --keyserver keyserver.ubuntu.com --recv DD45F6C3 gpg --export --armor DD45F6C3 | sudo apt-key add â
By the time this book goes into print, the key information might change. Refer to http://qgis.org/en/site/forusers/alldownloads.html#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
When you install QGIS, you get two applications: QGIS Desktop and QGIS Browser. If you are familiar with ArcGIS, you can think of QGIS Browser as similar to ArcCatalog. It is a small application to preview spatial data and related metadata. For the remainder of this book, we will focus on QGIS Desktop.
By default, QGIS uses the operating system's default language. To follow the tutorials in this book, I advise you to change the language to English by going to Settings | Options | Locale. On the first run, the way the toolbars are arranged can hide some buttons. To be able to work efficiently, I suggest that you rearrange the toolbars. I like to add some toolbars on the left and right screen borders to save vertical screen estateâespecially on wide screen displays.
Additionally, we activate the file browser by going to View | Panels | Browser. It provides us with a quick access to our spatial data. In the end, the QGIS window on your screen should look similar to the following screenshot:
Next, we activate some must-have plugins by going to Plugins | Manage and Install Plugins. Plugins are activated by ticking the checkboxes beside their names. To begin with, I recommend the following:
Now that we have set up QGIS, let's get accustomed to the interface! As we already saw in the screenshot presented in the Running QGIS for the first time section, the biggest area is reserved for the map. To the left of the map, there are the Layers and Browser panels. In the following screenshot, you can see how the Layers panel looks like once we have loaded some layers (which we will do in the upcoming chapter Viewing Spatial Data). To the left of each layer entry, you can see a preview of the layer style. Additionally, we can use layer groups to structure the layer list. The Browser panel (shown in the following screenshot) provides us with a quick access to our spatial data, as you will soon see in the following chapter.
Below the map, we find important information such as (from left to right) the current map Coordinates, map Scale, and the (currently inactive) project coordinate reference system (CRS), for example, EPSG:4326 in the following screenshot:
Next, there are multiple toolbars to explore. If you arrange them as shown in the previous section, the top row will look like this:
The first row contains the following toolbars:
File: This toolbar contains the tools to create, open, save, and print projects
Database: Currently, this toolbar only contains DB Manager, but other database-related tools (for example, the OfflineEditing plugin, which allows us to edit offline and synchronize with databases) will appear here when they are installed
The second row contains the following toolbars:
On the left screen border, we will add the following toolbar:
Finally, on the right screen border, we find the following toolbar:
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 will open a context menu with all the available toolbars and panels. All the tools on the toolbars 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 the clutter and save the screen estate, as shown in the following screenshot:
In this chapter, we installed QGIS and configured it by selecting useful defaults and arranging the user-interface elements. Finally, we explored the panels, toolbars, and menus that make up the QGIS user interface and learned how to customize them to increase productivity. In the following chapter, we will use QGIS to view spatial data from different data sources such as files, databases, and web services.