QGIS User Guide - OSGeo Server

QGIS User Guide - OSGeo Server




19.1 QGIS Plugins

QGIS has been designed with a plugin architecture. This allows many new features/functions to be easily added to the application. Many of the features in QGIS are actually implemented as either core or external plugins.

• Core Plugins are maintained by the QGIS Development Team and are automatically part of every QGIS distribution. They are written in one of two languages: C++ or Python. More information about core plugins are provided in Section

Using QGIS Core Plugins

• External Plugins are currently all written in Python. They are stored in external repositories and maintained by the individual authors. They can be added to QGIS using the Python Plugin Installer. More information about external plugins is provided in Section

Loading an external QGIS Plugin .

19.1.1 Managing Plugins

Managing plugins in general means loading or unloading them using the Plugin Manager. External plugins can be installed and directly activated or uninstalled using the Python Plugin Installer. To deactivate and reactivate external plugins, the Plugin Manager is used again.

Loading a QGIS Core Plugin

Loading a QGIS Core Plugin is done from the main menu Plugins → Manage Plugins

The Plugin Manager lists all the available plugins and their status (loaded or unloaded), including all core plugins and all external plugins that have been installed and automatically activated using the Python Plugin Installer (see


Loading an external QGIS Plugin ). Those plugins that are already loaded have a check mark to the left of

their name.


shows the Plugin Manager dialog.

To enable a particular plugin, click on the checkbox to the left of the plugin name, and click [OK]. When you exit the application, a list of loaded plugins is retained, and the next time you run QGIS these plugins are automatically loaded.

Tip: Crashing Plugins

If you find that QGIS crashes on startup, a plugin may be at fault. You can stop all plugins from loading by editing your stored settings file (see


for location). Locate the plugins settings and change all the plugin values to false to prevent them from loading.

For example, to prevent the ‘Delimited text’ plugin from loading, the entry in


on Linux should look like this: Add Delimited Text

Layer=false .


QGIS User Guide, Release 1.8.0

Figure 19.1: Plugin Manager

Do this for each plugin in the [Plugins] section. You can then start QGIS and add the plugins one at a time from the Plugin Manager to determine which plugin is causing the problem.

Loading an external QGIS Plugin

External QGIS plugins are written in Python. They are by default stored in either the ‘Official’ QGIS Repository, or in various other external repositories maintained by individual authors. The ‘Official’ QGIS Repository is added by default in Python Plugin installer.

Detailed documentation about the usage, minimum QGIS version, homepage, authors, and other important information are provided for the ‘Official’ QGIS Repository at http://plugins.qgis.org/plugins/ . For other external repositories, they might be available with the external plugins themselves. In general it is not included in this manual.

Note: Updates of core python plugins may be available in this repository as external overlays.

Note: fTools, Mapserver Export, and the Plugin Installer are Python plugins, but they are also part of the QGIS sources, and are automatically loaded and enabled inside the QGIS Plugin Manager (see Section

Loading an external QGIS Plugin ).

Currently there are over 150 external plugins available from the ‘Official’ QGIS Repository. Some of these plugins offer functionality that will be required by many users (for example: providing the user with the ability to view and edit OpenStreetMap data, or to add GoogleMap layers) while others offer very specialized functions (for example:

Calculate economic pipe diameters for water supply networks).

It is, however, quite straightforward to search through all the available external plugins by providing keywords, choosing a named repository and/or filtering on the status of plugins (currently installed or uninstalled in your system). Searching and filtering is done from the QGIS Python Plugin Installer (see

figure_plugins_2 ).

Tip: Add more repositories

To add external author repositories, open the Plugin Installer (Plugins → Fetch Python Plugins), go to the tab

198 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Repositories , and click [Add]. If you do not want one or more of the added repositories, they can be disabled via the [Edit...] button, or completely removed with the [Delete] button.

There is only one step required to integrate external plugins into QGIS:

• Download an external plugin from a repository using the Python Plugin Installer (see

Using the QGIS

Python Plugin Installer ). The new external plugin will be added to the list of available plugins in the Plugin

Manager and is automatically loaded.

Using the QGIS Python Plugin Installer

In order to download and install an external Python plugin, go to Plugins → Fetch Python Plugins . The Plugin


window will appear ( figure_plugins_2 ) with the tab Plugins, containing a list of all locally installed

Python plugins, as well as plugin available in remote repositories.

Figure 19.2: Installing external python plugins

Each plugin can be either:

• not installed - this means the plugin is available in the repository, but is not installed yet. In order to install it, select the plugin from the list and click the button [Install plugin].

• new - this means that the plugin is newly available in the repository.

• installed - this indicates that the plugin is already installed. If it is also available in any repository the

[Reinstall plugin] button will be enabled. If the available version is older than the installed version, the

[Downgrade plugin] button will appear instead.

• upgradeable - this means that the plugin is installed, but there is an updated version available. In this case, the [Upgrade plugin] and [Upgrade all] buttons will be enabled.

• invalid - this means that the plugin is installed, but is unavailable or broken. The reason will be explained in the plugin description field.

Plugins tab

To install a plugin, select it from the list and click the [Install plugin] button. The plugin is then activated and installed in its own directory.

• Linux and other unices

– /share/qgis/python/plugins

– $HOME/.qgis/python/plugins

• Mac OS X

– /Contents/MacOS/share/qgis/python/plugins

19.1. QGIS Plugins 199

QGIS User Guide, Release 1.8.0

– /Users/$USERNAME/.qgis/python/plugins

• Windows

– C:\Program Files\QGIS\python\plugins

– C:\Documents and Settings\$USERNAME\.qgis\python\plugins

If the installation is successful, a confirmation message will appear.

If the installation fails, the reason for the failure will be displayed in a warning dialog. Most often, errors are the result of connection problems and/or missing Python modules. In the former case you will likely need to wait before trying the install again, in the latter case, you should install the missing modules relevant to your operating system prior to using the plugin. For Linux, most required modules should be available via a package manager.

For install instructions in Windows visit the module home page.

If you are using a proxy, you may need to configure it under Edit → Options (Gnome, OSX) or Settings → Options

(KDE, Windows)‘ on the Proxy tab.

The [Uninstall plugin] button is enabled only if the selected plugin is installed and is not a core plugin. Note that if you have installed an update to a core plugin, you can uninstall this update with the [Uninstall plugin] and revert to the version shipped with Quantum GIS. This default version however, cannot be uninstalled.

Repositories tab

The second tab Repositories, contains a list of plugin repositories available for the Plugin Installer. By default, only the QGIS Official Repository is enabled. You can add several user-contributed repositories, including the central QGIS Contributed Repository and other external repositories by clicking the [Add ...] button. The added repositories contain a large number of useful plugins which are not maintained by the QGIS Development Team.

As such, we cannot take any responsibility for them. You can also manage the repository list manually, that is add, remove, and edit the entries. Temporarily disabling a particular repository is possible by clicking the [Edit

...] button.

Options tab

The Options tab is where you can configure the settings of the Plugin Installer. The Check for updates on startup checkbox tells QGIS to automatically look for plugin updates and news. By default, if this feature is enabled all repositories listed and enabled in the Repositories tab are checked for updates each time the program is started. The frequency of update checking can be adjusted using the dropdown menu, and may be adjusted from once a day right up to once a month. If a new plugin or update is available for one of the installed plugins, a notification will appear in the Status Bar. If the checkbox is disabled, looking for updates and news is performed only when the Plugin Installer is manually launched from the menu.

Although the plugin installer update can handle ports different from 80, some internet connections will cause problems when attempting to automatically check for updates. In these cases, a Looking for new plugins... indicator will remain visible in the Status Bar during your entire QGIS session, and may cause a program crash when exiting. In this case please disable the checkbox.

In addition, you may specify the type of plugins that are displayed by the Python Plugin Installer. Under Allowed plugins

, you can specify whether you would like to:

• Only show plugins from the official repository

Show all plugins except those marked as experimental

Show all plugins, even those marked as experimental

Tip: Using experimental plugins

Experimental plugins are generally unsuitable for production use. These plugins are in the early stages of development, and should be considered ‘incomplete’ or ‘proof of concept’ tools. The QGIS development team does not recommend installing these plugins unless you intend to use them for testing purposes.

200 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.1.2 Data Providers

Data Providers are ‘special’ plugins that provides access to a data store. By default, QGIS supports PostGIS layers and disk-based data stores supported by the GDAL/OGR library. A Data Provider plugin extends the ability of

QGIS to use other data sources.

Data Provider plugins are registered automatically by QGIS at startup. They are not managed by the Plugin

Manager but used behind the scenes when a data type is added as a layer in QGIS.

19.1. QGIS Plugins 201

QGIS User Guide, Release 1.8.0

19.2 Using QGIS Core Plugins

Icon Plugin

Add Delimited Text


Coordinate Capture

DB Manager

Diagram Overlay


Converter eVis fTools

GPS Tools


GDAL Tools





Loads text files containing x,y coordinates

Capture mouse coordinate in different


Manage your databases within QGIS

Add Diagrams for vectors

Converts from DXF to SHP file format

Event Visualization Tool

A suite of vector tools

Tools for loading and importing GPS data

GRASS functionality

GDAL raster functionality

Georeference Raster with GDAL

Manual Reference

Delimited Text Plugin

Coordinate Capture Plugin

DB Manager Plugin

Diagram Overlay Plugin

Dxf2Shp Converter Plugin eVis Plugin

fTools Plugin

GPS Plugin

GRASS GIS Integration

GDAL Tools Plugin

Georeferencer Plugin

Heatmap Plugin

Interpolation plugin

MapServer Export


Offline Editing


Oracle Spatial


Plugin Installer

Create heatmap raster from input vector points

Interpolation on base of vertices of a vector layer

Export a QGIS project file to a

MapServer map file

Offline editing and synchronizing with database

Access OpenStreetMap

Access Oracle Spatial GeoRasters

Download and install python plugins

Interpolation Plugin

MapServer Export Plugin

Offline Editing Plugin


Oracle GeoRaster Plugin

Raster Terrain


Road graph Plugin


Compute geomorphological features from DEMs

Shortest path analysis

Shapefile to PostGIS Import Tool

Using the QGIS Python Plugin


Raster Terrain Analysis Plugin

Road Graph Plugin

Importing Data into PostgreSQL

SQL Anywhere plugin

Spatial Query

Zonal Statistics

Access SQL anywhere DB

Spatial queries on vectors

Calculate raster statistics for vector polygons

SQL Anywhere Plugin

Spatial Query Plugin

Zonal Statistics Plugin

202 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.3 Coordinate Capture Plugin

The coordinate capture plugin is easy to use and provides the ability to display coordinates on the map canvas for two selected Coordinate Reference Systems (CRS).

Figure 19.3: Coordinate Capture Plugin

1. Start QGIS, select Project Properties from the Settings (KDE, Windows) or File (Gnome, OSX) menu and click on the Projection tab. As an alternative you can also click on the right-hand corner of the statusbar.

CRS status icon in the lower

2. Click on the Enable on the fly projection checkbox and select a projected coordinate system of your choice (see also

Working with Projections ).

3. Load the coordinate capture plugin in the Plugin Manager (see

Loading a QGIS Core Plugin ) and ensure

that the dialog is visible by going to View → Panels and ensuring that Coordinate Capture is enabled.

The coordinate capture dialog appears as shown in Figure

figure_coordinate_capture_1 .

4. Click on the selected above.

Click to the select the CRS to use for coordinate display icon and select a different CRS from the one you

5. To start capturing coordinates, click on [Start capture]. You can now click anywhere on the map canvas and the plugin will show the coordinates for both of your selected CRS.

6. To enable mouse coordinate tracking click the mouse tracking

7. You can also copy selected coordinates to the clipboard.


19.4 DB Manager Plugin

The DB Manager Plugin is officially part of QGIS core and intends to replace the SPIT Plugin and the PostGIS

Manager Plugin and additionally to integrate all other database formats supported by QGIS in one user interface.


DB Manager

Plugin provides several features. You can drag layers from the QGIS Browser into the DB

Manager and it will import your layer into your spatial database. You can drag and drop tables between spatial databases and they will get imported. You can also use the DB Manager to execute SQL queries against your spatial database and then view the spatial output for queries by adding the results to QGIS as a query layer.

The Database menu allows to connect to an existing database, to start the SQL-window and to exit the DB Manager

Plugin. The Schema menu includes tools to create and delete (empty) schemas and, if topology is available (e.g.

PostGIS 2) to start a TopoViewer. The menu Table allows to create and edit tables and to delete tables and views. It is also possible to empty tables and to move tables from one to another schema. Finally you can also run Vacuum

Analyze and add Versioning Support to a table.

The Tree window lists all existing databases supported by QGIS. With a double-click you can connect to the database. With the right-mouse button you can rename and delete existing schemas and tables. Tables can also be added to the QGIS canvas with the context menu.

19.3. Coordinate Capture Plugin 203

QGIS User Guide, Release 1.8.0

Figure 19.4: DB Manager dialog (KDE)

If connected to a database, the main window of the DB Manager offers three tabs. The Info tab provides information about the table and its geometry as well as about existing Fields, Constraints and Indexes. It also allows to run Vacuum Analyze and to create a spatial index on a selected table, if not already done. The Table tab shows all attributes and the Preview tab renders the geometries as preview.

19.5 Delimited Text Plugin

The Delimited Text plugin allows you to load a delimited text file as a layer in QGIS.

19.5.1 Requirements

To view a delimited text file as layer, the text file must contain:

1. A delimited header row of field names. This must be the first line in the text file.

2. The header row must contain an X and Y field. These fields can have any name.

3. The x and y coordinates must be specified as a number. The coordinate system is not important.

As an example of a valid text file we import the elevation point data file elevp.csv coming with the QGIS sample dataset (See Section

Sample Data ):


300120 ; 7689960 ; 13

654360 ; 7562040 ; 52

1640 ; 7512840 ; 3

[ ...


Some items of note about the text file are:

1. The example text file uses ; (semicolon) as delimiter. Any character can be used to delimit the fields.

2. The first row is the header row. It contains the fields X, Y and ELEV.

3. No quotes (") are used to delimit text fields.

4. The x coordinates are contained in the X field.

5. The y coordinates are contained in the Y field.

19.5.2 Using the Plugin

To use the plugin you must first enable it as described in Section

Managing Plugins .

204 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Click the new toolbar icon

ure_delimited_text_1 .

Add Delimited Text Layer to open the Delimited Text dialog as shown in


Figure 19.5: Delimited Text Dialog

First select the file (e.g., qgis_sample_data/csv/elevp.csv) to import by clicking on the [Browse] button. Once the file is selected, the plugin attempts to parse the file using the last used delimiter, in this case a semicolon (;). To properly parse the file, it is important to select the correct delimiter. To change the delimiter to tab use \t (this is a regular expression for the tab character).

Once the file is parsed, choose the X and Y fields from the dropdown lists and if available also the WKT field for the CRS information. Finally enter a Layer name (e.g., elevp ) as shown in


. To add the layer to the map, click [OK]. The delimited text file now behaves as any other map layer in QGIS.

19.6 Diagram Overlay Plugin

The Diagram Overlay Plugin allows you to add a graphic overlay to a vector layer (see

figure_overlay_1 ). It

provides additional and not yet implemented features to the Diagrams tab, described in secion

Diagrams Tab .

Before starting, the Diagram Overlay Plugin needs to be activated using the Plugin Manager (see Section

Loading a QGIS Core Plugin ). It will then appear as Overlay tab in the Layer Properties dialog next to the Diagrams tab.

The Overlay tab provides support for Pie charts, Bar charts and proportional SVG symbols.

Similar to the Diagrams tab, we will demonstrate an example and overlay the alaska boundary layer a piechart diagram showing some temperature data from a climate vector layer. Both vector layers are part of the QGIS sample dataset (see Section

Sample Data ).

1. First click on the

Load Vector icon, browse to the QGIS sample dataset folder and load the two vector shape layers alaska.shp and climate.shp.

19.6. Diagram Overlay Plugin 205

QGIS User Guide, Release 1.8.0

Figure 19.6: Vector properties dialog with overlay tab

2. Double click the climate layer in the map legend to open the Layer Properties dialog.

3. Click on the Overlay tab, activate combobox.

Display diagrams and select ‘Pie Chart’ from Diagram type

4. We want to display the values of the three columns T_F_JAN, T_F_JUL and T_F_MEAN. First select

T_F_JAN as Attributes and click the [Add] button, then T_F_JUL and finally T_F_MEAN.

5. Diagram size is based on linear scaling of a classification attribute. We choose T_F_JUL, click on [Find maximum value] and set size to 20 and Size unit to ‘Millimeter’.

6. Now click [Apply] to display the diagram in the QGIS main window.

7. You can now adapt the chart size, or change the attribute colors double clicking on the color values in the attribute field.


gives an impression.

8. Finally click [Ok].

Figure 19.7: Pie chart diagram from temperature data overlayed on a map

Additionally in the Settings → Options dialog, there is a Overlay tab where it is possible to select the placement

206 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

algorithm of the diagrams. The ‘Central point’ method is a generic one, the others use algorithms of the PAL library. They also consider diagram objects and labels in different layers.

19.7 Dxf2Shp Converter Plugin

The dxf2shape converter plugin can be used to convert vector data from DXF to Shapefile format. It requires the following parameters to be specified before running:

Figure 19.8: Dxf2Shape Converter Plugin

• Input DXF file: Enter path to the DXF file to be converted

• Output Shp file: Enter desired name of the Shapefile to be created

• Output file type: Specify the geometry type of the output Shapefile. Currently supported types are polyline, polygon, and point.

• Export text labels: When this checkbox is enabled, an additional Shapefile point layer will be created, and the associated dbf table will contain information about the “TEXT” fields found in the dxf file, and the text strings themselves.

19.7.1 Using the Plugin

1. Start QGIS, load the Dxf2Shape plugin in the Plugin Manager (see Section

Loading a QGIS Core Plugin )

and click on the

Dxf2Shape Converter icon which appears in the QGIS toolbar menu. The Dxf2Shape plugin dialog appears as shown in

Figure_dxf2shape_1 .

2. Enter input DXF file, a name for the output Shapefile and the Shapefile type.

3. Enable the

4. Click [OK].

Export text labels checkbox if you want to create an extra point layer with labels.

19.8 eVis Plugin

The Biodiversity Informatics Facility at the American Museum of Natural History’s (AMNH) Center for Biodiversity and Conservation (CBC) (this section is derived from Horning, N., K. Koy, P. Ersts. 2009. eVis (v1.1.0)

User’s Guide. American Museum of Natural History, Center for Biodiversity and Conservation. Available from http://biodiversityinformatics.amnh.org/ , and released under the GNU FDL.) has developed the Event Visualization Tool (eVis), another software tool to add to the suite of conservation monitoring and decision support tools for guiding protected area and landscape planning. This plugin enables users to easily link geocoded (i.e., referenced with latitude and longitude or X and Y coordinates) photographs, and other supporting documents, to vector data in QGIS.

19.7. Dxf2Shp Converter Plugin 207

QGIS User Guide, Release 1.8.0

eVis is now automatically installed and enabled in new versions of QGIS, and as with all plugins, it can be disabled and enabled using the Plugin Manager (See

Managing Plugins ).

The eVis plugin is made up of three modules: the ‘Database Connection tool’, ‘Event ID tool’, and the ‘Event

Browser’. These work together to allow viewing of geocoded photographs and other documents that are linked to features stored in vector files, databases, or spreadsheets.

19.8.1 Event Browser

The Event Browser module provides the functionality to display geocoded photographs that are linked to vector features displayed in the QGIS map window. Point data, for example, can be from a vector file that can be input using QGIS or it can be from the result of a database query. The vector feature must have attribute information associated with it to describe the location and name of the file containing the photograph and, optionally, the compass direction the camera was pointed when the image was acquired. Your vector layer must be loaded into

QGIS before running the Event Browser.

Launch the Event Browser module

To launch the Event browser module either click on the eVis Event Browser eVis Event Browser . This will open the Generic Event Browser window.

icon or click on Database → eVis →

The Generic Event Browser window has three tabs displayed at the top of the window. The Display tab is used to view the photograph and its associated attribute data. The Options tab provides a number of settings that can be adjusted to control the behavior of the eVis plugin. Lastly, the Configure External Applications tab is used to maintain a table of file extensions and their associated application to allow eVis to display documents other than images.

Understanding the Display window

To see the Display window click on the Display tab in the Generic Event Browser window. The Display window is used to view geocoded photographs and their associated attribute data.

1. Display window: A window where the photograph will appear.

2. Zoom in button: Zoom in to see more detail. If the entire image cannot be displayed in the display window, scroll bars will appear on the left and bottom sides of the window to allow you to pan around the image.

3. Zoom out button: Zoom out to see more area.

4. Zoom to full extent button: Displays the full extent of the photograph.

5. Attribute information window: All of the attribute information for the point associated with the photograph being viewed is displayed here. If the file type being referenced in the displayed record is not an image but is of a file type defined in the Configure External Applications tab then when you double-click on the value of the field containing the path to the file the application to open the file will be launched to view or hear the contents of the file. If the file extension is recognized the attribute data will be displayed in green.

6. Navigation buttons: Use the Previous and Next buttons to load the previous or next feature when more than one feature is selected.

7. Feature indicator: This heading indicates which feature is being displayed and how many features are available for display.

Understanding the Options window

1. File path: A dropdown list to specify the attribute field that contains the directory path or URL for the photographs or other documents being displayed. If the location is a relative path then the checkbox must be clicked. The base path for a relative path can be entered in the Base Path text box below. Information

208 Chapter 19. Plugins

Figure 19.9: The eVis display window

QGIS User Guide, Release 1.8.0

19.8. eVis Plugin

Figure 19.10: The eVis Options window


QGIS User Guide, Release 1.8.0

about the different options for specifying the file location are noted in the section

Specifying the location and name of a photograph


2. Compass bearing display field: A dropdown list to specify the attribute field that contains the compass bearing associated with the photograph being displayed. If compass bearing information is available it is necessary to click the checkbox to the left of the dropdown menu title.

3. Compass offset setting: Compass offsets can be used to compensate for declination (adjust bearings collected using magnetic bearings to true north bearings). Click the Manual radiobutton to enter the offset in the text box or click the From Attribute radiobutton to select the attribute field containing the offsets.

For both of these options east declinations should be entered using positive values and west declinations should use negative values.

4. Directory base path: The base path onto which the relative path defined in


(A) will be appended.

5. Replace path: If this checkbox is checked, only the file name from the A will be appended to the Base Path.

6. Apply rule to all documents: If checked, the same path rules that are defined for photographs will be used for non-image documents such as movies, text documents, and sound files. If not checked the path rules will only apply to photographs and other documents will ignore the Base Path parameter.

7. Save settings: If the checkbox is checked the values for the associated parameters will be saved for the next session when the window is closed or when the [Save] button below is pressed.

8. Reset values: Resets the values on this line to the default setting.

9. Restore faults: This will reset all of the fields to their default settings. It has the same effect as clicking all of the [Reset] buttons.

10. Save: This will save the settings without closing the Options pane.

Understanding the Configure External Applications window

Figure 19.11: The eVis External Applications window

1. File reference table: A table containing file types that can be opened using eVis. Each file type needs a file extension and the path to an application that can open that type of file. This provides the capability of opening a broad range of files such as movies, sound recordings, and text documents instead of only images.

2. Add new file type: Add a new file type with a unique extension and the path for the application that can open the file.

3. Delete current row: Delete the file type highlighted in the table and defined by a file extension and a path to an associated application.

19.8.2 Specifying the location and name of a photograph

The location and name of the photograph can be stored using an absolute or relative path or a URL if the photograph is available on a web server. Examples of the different approaches are listed in Table

evis_examples .

210 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0







1784017 C:\Workshop\eVis_Data\groundphotos\DSC_0168.JPG



1784017 /groundphotos/DSC_0169.JPG


1784015 http://biodiversityinform.org/testdata/DSC_0170.JPG


1784017 pdf:http://www.test.com/attach.php?attachment_id-12 76

19.8.3 Specifying the location and name of other supporting documents

Supporting documents such as text documents, videos, and sound clips can also be displayed or played by eVis.

To do this it is necessary to add an entry in the file reference table that can be accessed from the Configure External

Applications window in the Generic Event Browser that matches the file extension to an application that can be used to open the file. It is also necessary to have the path or URL to the file in the attribute table for the vector layer. One additional rule that can be used for URLs that don’t contain a file extension for the document you want to open is to specify the file extension before the URL. The format is — file extension:URL. The URL is preceded by the file extension and a colon, and is particularly useful for accessing documents from Wikis and other web sites that use a database to manage the web pages (see Table

evis_examples ).

19.8.4 Using the Generic Event Browser

When the Event Browser window opens a photograph will appear in the display window if the document referenced in the vector file attribute table is an image and if the file location information in the Options window is properly set. If a photograph is expected and it does not appear it will be necessary to adjust the parameters in the

Options window.

If a supporting document (or an image that does not have a file extension recognized by eVis) is referenced in the attribute table the field containing the file path will be highlighted in green in the attribute information window if that file extension is defined in the file reference table located in the Configure External Applications window. To open the document double-click on the green-highlighted line in the attribute information window. If a supporting document is referenced in the attribute information window and the file path is not highlighted in green then it will be necessary to add an entry for the file’s filename extension in the Configure External Applications window.

If the file path is highlighted in green but does not open when double-clicked it will be necessary to adjust the parameters in the Options window so the file can be located by eVis.

If no compass bearing is provided in the Options window a red asterisk will be displayed on top of the vector feature that is associated with the photograph being displayed. If a compass bearing is provided then an arrow will appear pointing in the direction indicated by the value in the compass bearing display field in the Generic

Event Browser window. The arrow will be centered over the point that is associated with the photograph or other document.

To close the Generic Event Browser window click on the [Close] button from the Display window.

19.8.5 Event ID Tool

The ‘Event ID’ module allows you to display a photograph by clicking on a feature displayed in the QGIS map window. The vector feature must have attribute information associated with it to describe the location and name of the file containing the photograph and optionally the compass direction the camera was pointed when the image was acquired. This layer must be loaded into QGIS before running the ‘Event ID’ tool.

Launch the Event ID module

To launch the ‘Event ID’ module either click on the

Event ID icon or click on Plugins → eVis → Event ID Tool.

This will cause the cursor to change to an arrow with an ‘i’ on top of it signifying that the ID tool is active.

To view the photographs linked to vector features in the active vector layer displayed in the QGIS map window, move the Event ID cursor over the feature and then click the mouse. After clicking on the feature, the Generic

Event Browser window is opened and the photographs on or near the clicked locality are available for display

19.8. eVis Plugin 211

QGIS User Guide, Release 1.8.0

in the browser. If more than one photograph is available, you can cycle through the different features using the

[Previous] and [Next] buttons. The other controls are described in the ref:evis_browser section of this guide.

19.8.6 Database connection

The ‘Database Connection’ module provides tools to connect to and query a database or other ODBC resource, such as a spreadsheet.

eVis can directly connect to four types of databases: Microsoft Access, PostgreSQL, MySQL, SQLite, and can also read from ODBC connections. When reading from an ODBC database (such as an Excel spreadsheet) it is necessary to configure your ODBC driver for the operating system you are using.

Launch the Database Connection module

To launch the ‘Database Connection’ module either click on the appropriate icon eVis Database Connection or click on Plugins → eVis → Database Connection. This will launch the Database Connection window. The window has three tabs: Predefined Queries, Database Connection, and SQL Query. The Output Console window at the bottom of the window displays the status of actions initiated by the different sections of this module.

Connect to a database

Click on the Database Connection tab to open the database connection interface. Next, use the Database Type combobox to select the type of database that you want to connect to. If a password or username is required, that information can be entered in the Username and Password textboxes.

Enter the database host in the Database Host textbox. This option is not available if you selected “MS Access” as the database type. If the database resides on your desktop you should enter “localhost”.

Enter the name of the database in the Database Name textbox. If you selected “ODBC” as the database type, you need to enter the data source name.

When all of the parameters are filled in, click on the [Connect] button. If the connection is successful, a message will be written in the Output Console window stating that the connection was established. If a connection was not established you will need to check that the correct parameters were entered above.

1. Database Type: A dropdown list to specify the type of database that will be used.

2. Database Host: The name of the database host.

3. Port The port number if a MySQL or PostgreSQL database type is selected.

4. Database Name The name of the database.

5. Connect A button to connect to the database using the parameters defined above.

6. Output Console The console window where messages related to processing are displayed.

7. Username: Username for use when a database is password protected.

8. Password: Password for use when a database is password protected.

9. Predefined Queries: Tab to open the “Predefined Queries” window.

10. Database Connection: Tab to open the “Database Connection” window.

11. SQL Query: Tab to open the “SQL Query” window.

12. Help: Displays the on line help.

13. OK: Close the main “Database Connection” window.

212 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.12: The eVis Database connection window

Running SQL queries

SQL queries are used to extract information from a database or ODBC resource. In eVis the output from these queries is a vector layer added to the QGIS map window. Click on the SQL Query tab to display the SQL query interface. SQL commands can be entered in this text window. A helpful tutorial on SQL commands is available at http://www.w3schools.com/sql . For example, to extract all of the data from a worksheet in an Excel file, select

* from [sheet1$] where sheet1 is the name of the worksheet.

Click on the [Run Query] button to execute the command. If the query is successful a Database File Selection window will be displayed. If the query is not successful an error message will appear in the Output Console window.

In the Database File Selection window, enter the name of the layer that will be created from the results of the query in the Name of New Layer textbox.

1. SQL Query Text Window: A screen to type SQL queries.

2. Run Query: Button to execute the query entered in the SQL Query Window.

3. Console Window: The console window where messages related to processing are displayed.

4. Help: Displays the on line help.

5. OK: Closes the main Database Connection window.

Use the X Coordinate and Y Coordinate comboboxes to select the field from the database that store the X (or longitude) and Y (or latitude) coordinates. Clicking on the [OK] button causes the vector layer created from the SQL query to be displayed in the QGIS map window.

To save this vector file for future use, you can use the QGIS ‘Save as...’ command that is accessed by right clicking on the layer name in the QGIS map legend and then selecting ‘Save as...’

Tip: Creating a vector layer from a Microsoft Excel Worksheet

19.8. eVis Plugin 213

QGIS User Guide, Release 1.8.0

Figure 19.13: The eVis SQL query tab

When creating a vector layer from a Microsoft Excel Worksheet you might see that unwanted zeros (“0”) have been inserted in the attribute table rows beneath valid data.This can be caused by deleting the values for these cells in Excel using the Backspace key. To correct this problem you need to open the Excel file (you’ll need to close

QGIS if there if you are connected to the file to allow you to edit the file) and then use Edit → Delete to remove the blank rows from the file. To avoid this problem you can simply delete several rows in the Excel Worksheet using Edit → Delete before saving the file.

Running predefined queries

With predefined queries you can select previously written queries stored in XML format in a file. This is particularly helpful if you are not familiar with SQL commands. Click on the Predefined Queries tab to display the predefined query interface.

To load a set of predefined queries click on the

Open File icon. This opens the Open File window which is used to locate the file containing the SQL queries. When the queries are loaded their titles, as defined in the XML file, will appear in the dropdown menu located just below the displayed in the text window under the dropdown menu.

Open File icon, the full description of the query is

Select the query you want to run from the dropdown menu and then click on the SQL Query tab to see that the query has been loaded into the query window. If it is the first time you are running a predefined query or are switching databases, you need to be sure to connect to the database.

Click on the [Run Query] button in the SQL Query tab to execute the command. If the query is successful a

Database File Selection window will be displayed. If the query is not successful an error message will appear in the Output Console window.

1. Open Query File: Launches the “Open File” file browser to search for the XML file holding the predefined queries.

2. Predefined Queries: A dropdown list with all of the queries defined by the predefined queries XML file.

214 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.14: The eVis Predefined queries tab

3. Query description: A short description of the query. This description is from the predefined queries XML file.

4. Console Window: The console window where messages related to processing are displayed.

5. Help: Displays the on line help.

6. OK: Closes the main “Database Connection” window.

XML format for eVis predefined queries

The XML tags read by eVis

19.8. eVis Plugin 215

QGIS User Guide, Release 1.8.0

Tag query shortdescription description


Defines the beginning and end of a query statement.

A short description of the query that appears in the eVis dropdown menu.

A more detailed description of the query displayed in the Predefined Query text window.

databasetype databaseport

The database type as defined in the Database Type dropdown menu in the Database Connection tab.

The port as defined in the Port textbox in the Database Connection tab.


The database name as defined in the Database Name textbox in the Database Connection tab.

databaseuserThe database username as defined in the Username textbox in the Database Connection tab.


The database password as defined in the Password textbox in the Database Connection tab.

databasepassword sqlstatement autoconnect

The SQL command.

A flag (“true”” or “false”) to specify if the above tags should be used to automatically connect to database without running the database connection routine in the Database Connection tab.

A complete sample XML file with three queries is displayed below:

<?xml version="1.0"?>



<shortdescription>Import all photograph points</shortdescription>

<description>This command will import all of the data in the SQLite database to QGIS



<databasehost />

<databaseport />

<databasename>C:\textbackslash Workshop/textbackslash eVis\_Data\textbackslash PhotoPoints.db</databasename>

<databaseusername />

<databasepassword />

<sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN

Points ON Points.rec_id=Attributes.point_ID</sqlstatement>




<shortdescription>Import photograph points "looking across Valley"</shortdescription>

<description>This command will import only points that have photographs "looking across a valley" to QGIS</description>


<databasehost />

<databaseport />


<databaseusername />

<databasepassword />

<sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN

Points ON Points.rec_id=Attributes.point_ID where COMMENTS=’Looking across valley’</sqlstatement>




<shortdescription>Import photograph points that mention "limestone"</shortdescription>

<description>This command will import only points that have photographs that mention

"limestone" to QGIS</description>


<databasehost />

<databaseport />

216 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0


<databaseusername />

<databasepassword />

<sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN

Points ON Points.rec_id=Attributes.point_ID where COMMENTS like ’%limestone%’





19.9 fTools Plugin

The goal of the fTools python plugin is to provide a one-stop resource for many common vector-based GIS tasks, without the need for additional software, libraries, or complex workarounds. It provides a growing suite of spatial data management and analysis functions that are both fast and functional.

fTools is now automatically installed and enabled in new versions of QGIS, and as with all plugins, it can be disabled and enabled using the Plugin Manager (See Section

Loading a QGIS Core Plugin ). When enabled, the

fTools plugin adds a Vector menu to QGIS, providing functions ranging from Analysis and Research Tools to

Geometry and Geoprocessing Tools, as well as several useful Data Management Tools.

19.9.1 Analysis tools

Icon Tool




Measure distances between two point layers, and output results as a) Square distance matrix, b) Linear distance matrix, or c) Summary of distances. Can limit distances to the k nearest features.

Calculate the total sum of line lengths for each polygon of a polygon vector layer.

Sum line length

Points in polygon

List unique values

Count the number of points that occur in each polygon of an input polygon vector layer.

List all unique values in an input vector layer field

Basic statistic


Neighbor analysis

Compute basic statistics (mean, std dev, N, sum, CV) on an input field.

Compute nearest neighbor statistics assess the level of clustering in a point vector layer

Mean coordinate(s)

Compute either the normal or weighted mean center of an entire vector layer, or multiple features based on a unique ID field.

Line intersections

Locate intersections between lines, and output results as a point shapefile. Useful for locating road or stream intersections, ignores line intersections with length > 0.

Table Ftools 1: fTools Analysis tools

19.9. fTools Plugin 217

QGIS User Guide, Release 1.8.0

19.9.2 Research tools

Icon Tool

Random selection

Random selection within subsets

Random points


Randomly select n number of features, or n percentage of features

Randomly select features within subsets based on a unique ID field.

Generate pseudo-random points over a given input layer.

Regular points Generate a regular grid of points over a specified region and export them as a point shapefile.

Generate a line or polygon grid based on user specified grid spacing.

Vector grid

Select by location Select features based on their location relative to another layer to form a new selection, or add or subtract from the current selection.

Polygon from layer extent

Create a single rectangular polygon layer from the extent of an input raster or vector layer.

Table Ftools 2: fTools Research tools

19.9.3 Geoprocessing tools

Icon Tool

Convex hull(s)




Symmetrical difference



Create minimum convex hull(s) for an input layer, or based on an ID field.

Create buffer(s) around features based on distance, or distance field.

Overlay layers such that output contains areas where both layers intersect.

Overlay layers such that output contains intersecting and non-intersecting areas.

Overlay layers such that output contains those areas of the input and difference layers that do not intersect.

Overlay layers such that output contains areas that intersect the clip layer.



Overlay layers such that output contains areas not intersecting the clip layer.

Merge features based on input field. All features with identical input values are combined to form one single feature.

Table Ftools 3: fTools Geoprocessing tools

218 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.9.4 Geometry tools

Icon Tool

Check geometry

Export/Add geometry columns

Polygon centroids


Check polygons for intersections, closed-holes, and fix node ordering.

Add vector layer geometry info to point (XCOORD, YCOORD), line

(LENGTH), or polygon (AREA, PERIMETER) layer.

Calculate the true centroids for each polygon in an input polygon layer.

Delaunay triangulation

Voronoi Polygons

Calculate and output (as polygons) the delaunay triangulation of an input point vector layer.

Calculate voronoi polygons of an input point vector layer.

Simplify geometry Generalize lines or polygons with a modified Douglas-Peucker algorithm.

Densify geometry Densify lines or polygons by adding vertices

Multipart to singleparts

Convert multipart features to multiple singlepart features. Creates simple polygons and lines.

Singleparts to multipart

Polygons to lines

Merge multiple features to a single multipart feature based on a unique ID field.

Lines to polygons

Convert polygons to lines, multipart polygons to multiple singlepart lines.

Convert lines to polygons, multipart lines to multiple singlepart polygons.

Extract nodes Extract nodes from line and polygon layers and output them as points.

Table Ftools 4: fTools Geometry tools

Note: The Simplify geometry tool can be used to remove duplicate nodes in line and polygon geometries, just set the Simplify tolerance parameter to 0 and this will do the trick.

19.9.5 Data management tools

Icon Tool Purpose

Define projection

Join attributes by location

Split vector layer

Specify the CRS for shapefiles whose CRS has not been defined.

Join additional attributes to vector layer based on spatial relationship. Attributes from one vector layer are appended to the attribute table of another layer and exported as a shapefile.

Split input layer into multiple separate layers based on input field.

Merge shapefiles to one

Create spatial index

Merge several shapefiles within a folder into a new shapefile based on the layer type

(point, line, area).

Create a spatial index for OGR supported formats.

Table Ftools 5: fTools Data management tools

19.9. fTools Plugin 219

QGIS User Guide, Release 1.8.0

19.10 GDAL Tools Plugin

19.10.1 What is GDALTools?

The GDAL Tools plugin offers a GUI to the collection of tools in the Geospatial Data Abstraction Library, http://gdal.osgeo.org

. These are raster management tools to query, re-project, warp and merge a wide variety of raster formats. Also included are tools to create a contour (vector) layer, or a shaded relief from a raster DEM, and to make a vrt (Virtual Raster Tile in XML format) from a collection of one or more raster files. These tools are available when the plugin is installed and activated.

The GDAL Library

The GDAL library consists of a set of command line programs, each with a large list of options. Users comfortable with running commands from a terminal may prefer the command line, with access to the full set of options. The

GDALTools plugin offers an easy interface to the tools, exposing only the most popular options.

19.10.2 List of GDAL tools

Figure 19.15: The GDALTools menu list




Assign projection

Extract projection

This utility is an image mosaicing, reprojection and warping utility. The program can reproject to any supported projection, and can also apply GCPs stored with the image if the image is “raw” with control information. For more information you can read on the GDAL website http://www.gdal.org/gdalwarp.html

This tool allows to assign projection to rasters that already georeferenced but miss projection information. Also with it help it is possible to alter existing projection definition. Both single file and batch mode are supported. For more information please visit utility page at GDAL site http://www.gdal.org/gdalwarp.html

This utility helps you to extract projection information from an input file. If you want to extract projection from a whole directory you can use the Batch mode. It creates both .prj

and .wld files.

220 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0







This program burns vector geometries (points, lines and polygons) into the raster band(s) of a raster image. Vectors are read from OGR supported vector formats. Note that the vector data must in the same coordinate system as the raster data; on the fly reprojection is not provided. For more information see http://www.gdal.org/gdal-rasterize.html

This utility creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. Each polygon is created with an attribute indicating the pixel value of that polygon. The utility will create the output vector datasource if it does not already exist, defaulting to ESRI shapefile format. See also http://www.gdal.org/gdal_polygonize.html

This utility can be used to convert raster data between different formats, potentially performing some operations like subsettings, resampling, and rescaling pixels in the process. For more information you can read on http://www.gdal.org/gdal_translate.html

This utility will compute an optimal pseudo-color table for a given RGB image using a median cut algorithm on a downsampled RGB histogram. Then it converts the image into a pseudo-colored image using the color table. This conversion utilizes Floyd-Steinberg dithering

(error diffusion) to maximize output image visual quality. The utility is also desribed at http://www.gdal.org/rgb2pct.html

This utility will convert a pseudocolor band on the input file into an output RGB file of the desired format. For more information see http://www.gdal.org/pct2rgb.html



This program generates a vector contour file from the input raster elevation model (DEM). On http://www.gdal.org/gdal_contour.html

you can find more information.


This utility allows to clip (extract subset) raster using selected extent or based on mask layer bounds. More information can be found at http://www.gdal.org/gdal_translate.html


19.10. GDAL Tools Plugin 221

QGIS User Guide, Release 1.8.0





Fill nodata

This utility removes raster polygons smaller than a provided threshold size (in pixels) and replaces them with the pixel value of the largest neighbor polygon. The result can be written back to the existing raster band, or copied into a new file. For more information see http://www.gdal.org/gdal_sieve.html


This utility will scan an image and try to set all pixels that are nearly black (or nearly white) around the edge to exactly black (or white). This is often used to “fix up” lossy compressed aerial photos so that color pixels can be treated as transparent when mosaicing. See also http://www.gdal.org/nearblack.html


This utility fills selection raster regions (usually nodata areas) by interpolation from valid pixels around the edges of the area. On http://www.gdal.org/gdal_fillnodata.html

you can find more information.

Proximity This utility generates a raster proximity map indicating the distance from the center of each pixel to the center of the nearest pixel identified as a target pixel. Target pixels are those in the source raster for which the raster pixel value is in the set of target pixel values. For more information see http://www.gdal.org/gdal_proximity.html


Grid This utility creates regular grid (raster) from the scattered data read from the OGR datasource. Input data will be interpolated to fill grid nodes with values, you can choose from various interpolation methods. The utility is also described on the GDAL website http://www.gdal.org/gdal_grid.html


DEM terrain models

Tools to analyze and visualize DEMs. It can create a shaded relief, a slope, an aspect, a color relief, a Terrain Ruggedness Index, a Topographic Position Index and a roughness map from any GDAL-supported elevation raster. For more information you can read on http://www.gdal.org/gdaldem.html






This program builds a VRT (Virtual Dataset) that is a mosaic of the list of input gdal datasets.

See also http://www.gdal.org/gdalbuildvrt.html







This utility will automatically mosaic a set of images. All the images must be in the same coordinate system and have a matching number of bands, but they may be overlapping, and at different resolutions. In areas of overlap, the last image will be copied over earlier ones. The utility is also described on http://www.gdal.org/gdal_merge.html


This utility lists various information about a GDAL supported raster dataset. On http://www.gdal.org/gdalinfo.html

you can find more information.

The gdaladdo utility can be used to build or rebuild overview images for most supported file formats with one of several downsampling algorithms. For more information see http://www.gdal.org/gdaladdo.html


This utility builds a shapefile with a record for each input raster file, an attribute containing the filename, and a polygon geometry outlining the raster. See also http://www.gdal.org/gdaltindex.html


222 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.11 Georeferencer Plugin

The Georeferencer Plugin is a tool for generating world files for rasters. It allows you to reference rasters to geographic or projected coordinate systems by creating a new GeoTiff or by adding a world file to the existing image. The basic approach to georeferencing a raster is to locate points on the raster for which you can accurately determine their coordinates.


Icon Purpose Icon Purpose

Open raster

Generate GDAL Script

Save GCP Points As

Add Point

Move GCP Point

Zoom In

Zoom To Layer

Zoom Next

Link QGIS to Georeferencer

Table Georeferencer 1: Georeferencer Tools

Start georeferencing

Load GCP Points

Transformation settings

Delete Point


Zoom Out

Zoom Last

Link Georeferencer to QGIS

19.11.1 Usual procedure

As X and Y coordinates (DMS (dd mm ss.ss), DD (dd.dd) or projected coordinates (mmmm.mm) which correspond with the selected point on the image, two alternative procedures can be used:

• The raster itself sometimes provides crosses with coordinates “written” on the image. In this case you can enter the coordinates manually.

• Using already georeferenced layers, this can be either vector or raster data that contain the same objects/features that you have on the image that you want to georeference and the projection you want to have your image. In this case you can enter the coordinates by clicking on the reference dataset loaded in

QGIS map canvas.

The usual procedure for georeferencing an image involves selecting multiple points on the raster, specifying their coordinates, and choosing a relevant transformation type. Based on the input parameters and data, the plugin will compute the world file parameters. The more coordinates you provide, the better the result will be.

The first step is to start QGIS, load the Georeferencer Plugin (see Section

Loading a QGIS Core Plugin ) and click

on the

Georeferencer icon which appears in the QGIS toolbar menu. The Georeferencer Plugin dialog appears as shown in

figure_georeferencer_1 .

For this example, we are using a topo sheet of South Dakota from SDGS. It can later be visualized together with the data from the GRASS spearfish60 location.

You can download the topo sheet here: http://grass.osgeo.org/sampledata/spearfish_toposheet.tar.gz


Entering ground control points (GCPs)

1. To start georeferencing an unreferenced raster, we must load it using the button. The raster will show up in the main working area of the dialog. Once the raster is loaded, we can start to enter reference points.

19.11. Georeferencer Plugin 223

QGIS User Guide, Release 1.8.0

Figure 19.16: Georeferencer Plugin Dialog

2. Using the

Add Point button, add points to the main working area and enter their coordinates (see Figure

figure_georeferencer_2 ). For this procedure you have three options:

• Click on a point in the raster image and enter the X and Y coordinates manually.

• Click on a point in the raster image and choose the button from map canvas to add the X and Y coordinates with the help of a georeferenced map already loaded in the QGIS map canvas.

• With the button, you can move the GCPs in both windows, if they are at the wrong place.

3. Continue entering points. You should have at least 4 points, and the more coordinates you can provide, the better the result will be. There are additional tools on the plugin dialog to zoom and pan the working area in order to locate a relevant set of GCP points.

Figure 19.17: Add points to the raster image

The points that are added to the map will be stored in a separate text file ([filename].points) usually together with the raster image. This allows us to reopen the Georeferencer plugin at a later date and add new points or delete existing ones to optimize the result. The points file contains values of the form: mapX, mapY, pixelX, pixelY

. You can use the

Load GCP Points and

Save GCP Points buttons to manage the files.

Within the GCP table you can click on a column header and therewith enable e.g. numerical sorting. The GCP list is automatically updated.

Defining the transformation settings

After you have added your GCPs to the raster image, you need to define the transformation settings for the georeferencing process.

224 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.18: Defining the georeferencer transformation settings

Available Transformation algorithms

Depending on how many ground control point you have captured, you may want to use different transformation algorithms. Choice of transformation algorithm is also dependent on the type and quality of input data and the amount of geometric distortion that you are willing to introduce to final result.

Currently, following algorithms are available:

• The Linear algorithm is used to create a world-file, and is different from the other algorithms, as it does not actually transform the raster. This algorithm likely won’t be sufficient if you are dealing with scanned material.

• The Helmert transformation performs simple scaling and rotation transformations.

• The Polynomial algorithms 1-3 are among the most widely used algorithms for georeferencing, and each one differs by the degree of distortion introduced to match source and destination ground control points.

The most widely used polynomial algorithm is the second order polynomial transformation, which allows some curvature. First order polynomial transformation (affine) preserves colliniarity and allows scaling, translation and rotation only.

• The Thin plate spline (TPS) algorithm is a more modern georeferencing method, which is able to introduce local deformations in the data. This algorithm is useful when very low quality originals are being georeferenced.

• The Projective transformation is a linear rotation and translation of coordinates.

Define the Resampling method

The type of resampling you choose will likely depending on your input data and the ultimate objective of the exercise. If you don’t want to change statistics of the image, you might want to choose ‘Nearest neighbour’, whereas a ‘Cubic resampling’ will likely provide a more smoothed result.

It is prossible to choose between five different resampling methods.

1. Nearest neighbour

2. Linear

3. Cubic

19.11. Georeferencer Plugin 225

QGIS User Guide, Release 1.8.0

4. Cubic Spline

5. Lanczos

Define the transformation settings

There are several options that need to be defined for the georeferenced output raster.

• The checkbox Create world file is only available, if you decide to use the linear transformation type, because this means that the raster image actually won’t be transformed. In this case, the field Output raster is not activated, because only a new world-file will be created.

• For all other transformation type you have to define an Output raster.

As default a new file ([filename]_modified) will be created in the same folder together with the original raster image.

• As a next step you have to define the Target SRS (Spatial Reference System) for the georeferenced raster

(see section

Working with Projections ).

• If you like, you can generate a pdf map and also a pdf report. The report includes information about the used transformation parameters. An image of the residuals and a list with all GCPs and their RMS errors.

• Furthermore you can activate the Set Target Resolution checkbox and define pixel resolution of the output raster. Default horizontal and vertical resolution is 1,

• The Use 0 for transparency when needed can be activated, if pixels with the value 0 shall be visualized transparent. In our example toposheet all white areas would be transparent.

• Finally Load in QGIS when done loads the output raster automatically into the QGIS map canvas when the transformation is done.

Show and adapt raster properties

Clicking on the Raster properties dialog in the Settings menu opens the raster properties of the layer that you want to georeference.

Configure the georeferencer

• You can define if you want to show GCP coordiniates and/or IDs.

• As residual units pixels and map units can be chosen.

• For the PDF report a left and right margin can be defined and you can also set the paper size for the PDF map.

• Finally you can activate to show georeferencer window docked .

Running the transformation

After all GCPs have been collected and all transformation settings are defined, just press the button

Start georeferencing to create the new georeferenced raster.

19.12 Interpolation Plugin

The Interplation plugin can be used to generate a TIN or IDW interpolation of a point vector layer. It is very simple to handle and provides an intuitive graphical user interface for creating interpolated raster layers (See

Figure_interpolation_1 ). The plugin requires the following parameters to be specified before running:

226 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

• Input vector layer: Specify the input point vector layer(s) from a list of loaded point layers. If several layers are specified, then data from all layers is used for interpolation. Note: It is possible to insert lines or polygons as constraints for the triangulation, by specifying either “points”, “structure lines” or “break lines” in the Type combobox.

• Interpolation attribute: Select attribute column to be used for interpolation or enable the

Coordinate checkbox to use the layers stored Z values.

Use Z-

• Interpolation Method: Select interpolation method. This can be either ‘Triangulated Irregular Network

(TIN)’ or ‘Inverse Distance Weighted (IDW)’.

• Number of columns/rows: Specify the number row and colums for the output raster file.

• Output file: Specify a name for the output raster file.

Figure 19.19: Interpolation Plugin

19.12.1 Using the plugin

1. Start QGIS and load a point vector layer (e.g., elevp.csv).

2. Load the Interpolation plugin in the Plugin Manager (see Section

Loading a QGIS Core Plugin ) and click

on the

Interpolation icon which appears in the QGIS toolbar menu. The Interpolation plugin dialog appears as shown in

Figure_interpolation_1 .

3. Select an input layer (e.g., elevp ) and column (e.g., ELEV) for interpolation.

4. Select an interpolation method (e.g. ‘Triangulated Irregular Network (TIN)’), and specify a cellsize of 5000 as well as the raster output filename (e.g., elevation_tin).

5. Click [OK].

6. For the current example, double click elevation_tin in the layer list to open the raster Layer Properties dialog and select ‘Pseudocolor’ as Color Map table as described in section

Working with Raster Data .

in the Symbology tab. Or you can define a new color

19.13 MapServer Export Plugin

You can use QGIS to ‘compose’ your map by adding and arranging layers, symbolizing them, customizing the colors and then creating a map file for MapServer.

Note: Currently the plugin only works when you use ‘Old Symbology’ in QGIS. ‘New Symbology’ is not yet supported.

19.13. MapServer Export Plugin 227

QGIS User Guide, Release 1.8.0

19.13.1 Creating the Project File

The MapServer Export Plugin operates on a saved QGIS project file and not on the current contents of the map canvas and legend. This has been a source of confusion for a number of users. As described below, before you start using the MapServer Export Plugin, you need to arrange the raster and vector layers you want to use in MapServer and save this status in a QGIS project file.

Figure 19.20: Arrange raster and vector layers for QGIS project file

In this example, we demonstrate the four steps required to create a simple project file which can be used to create the MapServer map file. We use raster and vector files from the QGIS sample dataset

Sample Data .

1. Add the raster layer landcover.tif clicking on the

Add Raster Layer icon.

2. Add the vector Shapefiles lakes.shp, majrivers.shp and airports.shp from the QGIS sample dataset clicking on the

Add Vector Layer icon.

3. Change the colors and symbolize the data as you like (for example see

figure_mapserver_export_1 )

4. Save a new project named mapserverproject.qgs using File → Save Project .

19.13.2 Creating the Map File

To use the Mapserver Export plugin from within QGIS, you need to enable the MapServer Export Plugin first using the Plugin Manager (see

Loading a QGIS Core Plugin ).

228 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.21: Export to MapServer Dialog

Map file

Qgis project file









Image type







Enter the name for the map file to be created. You can use the button at the right to browse for the directory where you want the map file created.

Enter the full path to the QGIS project file (.qgs) you want to export. You can use the button at the right to browse for the QGIS project file.

A name for the map. This name is prefixed to all images generated by the mapserver.

Width of the output image in pixels.

Height of the output image in pixels.

Units of measure used for output.

Format for the output image generated by MapServer

Full path to the MapServer template file to be used with the map file

Full path to the MapServer header file to be used with the map file

Full path to the MapServer footer file to be used with the map file

Only the inputs Map file and QGIS project file are required to create a map file, however by omitting the other parameters, you may end up creating a non-functional map file, depending on your intended use. Although QGIS is good at creating a map file from your project file, it may require some tweaking to get the results you want. For this example, we will create a map file using the project file mapserverproject.qgs we just created (see

Figure_mapserver_export_2 ):

1. Click the

MapServer Export

ure_mapserver_export_2 ).

icon in the toolbar menu to start the MapServer dialog (see


2. Enter the name (e.g., qgisproject.map) for your new map file.

3. Browse and find the QGIS project file (e.g., mapserverproject.qgs) you previously saved.

4. Enter a name (e.g., MyMap) for the map.

5. Enter the width and height (e.g., 600 for the width and 400 for the height) for your output image.

6. For this example, the layers are in meters, so we change the units to meters.

19.13. MapServer Export Plugin 229

QGIS User Guide, Release 1.8.0

7. Choose png for the image type.

8. Click [OK] to generate the new map file qgisproject.map. QGIS displays the success of your efforts.

Figure 19.22: Export to MapServer Succesfull Dialog

You can view the map file in any text editor or visualizer. If you take a look, you’ll notice that the export tool adds the metadata needed to enable our map file for WMS.

19.13.3 Troubleshooting

If you get error messages from mapserver like: loadSymbolSet(): Unable to access file. (./symbols/symbols.txt) or: msLoadFontset(): Unable to access file. Error opening fontset ./fonts/fonts.txt.

This means that that the map file is requesting for fonts or symbol definition files but that Mapserver cannot find those.

Either comment the lines containing those names in the map file (this is possible if you do not have labels or use styles from the symbols.txt). Or create those files (see below).

The most simple fonts.txt file (because arial is used in the QGIS generated map files) contains the following line

# either relative to the map file or a full path: arial / usr / share / fonts / truetype / msttcorefonts / arial .


The most simple symbols.txt file contains the definition of a circle symbol (because a circle symbol is used for point layers)



NAME "circle"

TYPE ellipse



1 1




230 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.13.4 Testing the Map File

We can now test our work.

If the map file is accessible for you mapserver cgi you can use the one of the url’s from the success dialog.

Another option is using the shp2img tool to create an image from the map file. The shp2img utility is part of

MapServer and FWTools. To create an image from our map:

• Open a terminal window

• If you didn’t save your map file in your home directory, change to the folder where you saved it.

• Run shp2img -m qgisproject.map -o mapserver\_test.png and display the image

This creates a PNG with all the layers included in the QGIS project file. In addition, the extent of the PNG will be the same as when we saved the project. As you can see in

figure_mapserver_export_4 , all information except the

airport symbols are included.

Figure 19.23: Test PNG created by shp2img with all MapServer Export layers

19.13.5 Using Map File

If you plan to use the map file to serve WMS requests, you probably don’t have to tweak anything. If you plan to use it with a mapping template or a custom interface, you may have a bit of manual work to do. To see how easy it is to go from QGIS to serving maps on the web, take a look at Christopher Schmidt’s 5 minute flash video . He used an older version of QGIS (version 0.8), but the demo applies equally well to newer versions.

19.14 Offline Editing Plugin

For data collection, it is a common situation to work with a laptop or a cell phone offline in the field. Upon returning to the network, the changes need to be synchronized with the master data source, e.g. a PostGIS database.

If several persons are working simultaneously on the same datasets, it is difficult to merge the edits by hand, even if people don’t change the same features.


Offline Editing

Plugin automates the synchronisation by copying the content of a datasource (usually PostGIS or WFS-T) to a SpatiaLite database and storing the offline edits to dedicated tables. After being connected to the network again, it is possible to apply the offline edits to the master dataset.

19.14. Offline Editing Plugin 231

QGIS User Guide, Release 1.8.0

19.14.1 Using the plugin

• Open some vector layers, e.g. from a PostGIS or WFS-T datasource

• Save it as a project

• Press the

Convert to offline project

SpatiaLite tables.

icon and select the layers to save. The content of the layers is saved to

• Edit the layers offline.

• After being connected again, upload the changes with the

Synchronize button.

Figure 19.24: Create an offline project from PostGIS or WFS layers

19.15 Oracle GeoRaster Plugin

In Oracle databases, raster data can be stored in SDO_GEORASTER objects available with the Oracle Spatial extension. In QGIS, the

OracleGeoRasterPlugin is supported by GDAL, and depends on Oracle’s database product being installed and working on your machine. While Oracle is proprietary software, they provide their software free for development and testing purposes. Here is one simple example of how to load raster images to GeoRaster:

$ gdal_translate -of georaster input_file.tif geor:scott/[email protected]

This will load the raster into the default GDAL_IMPORT table, as a column named RASTER.

19.15.1 Managing connections

Firstly, the Oracle GeoRaster Plugin must be enabled using the Plugin Manager (see Section

Loading a QGIS

Core Plugin ). The first time you load a GeoRaster in QGIS, you must create a connection to the Oracle database

that contains the data. To do this, begin by clicking on the

Select GeoRaster toolbar button, it will open the Select

Oracle Spatial GeoRaster dialog window. Click on [New] to open the dialog window, and specify the connection parameters (See

Figure_oracle_raster_1 ):

• Name: Enter a name for the database connection

232 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

• Database instance: Enter the name of the database that you will connect to

• Username: Specify your own username that you will use to access the database

• Password: The password associated with your username that is required to access the database

Figure 19.25: Create Oracle connection dialog

Now, back on the main Oracle Spatial GeoRaster dialog window (see

Figure_oracle_raster_2 ), use the drop-down

list to choose one connection, and use the [Connect] button to establish a connection. You may also [Edit] the connection by opening the previous dialog and making changes to the connection information, or use the [Delete] button to remove the connection from the drop-down list.

19.15.2 Selecting a GeoRaster

Once a connection has been established, the sub-datasets window will show the names of all the tables that contains

GeoRaster columns in that database in the format of a GDAL subdataset name.

Click on one of the listed subdatasets and then click on [Select] to choose the table name. Now another list of subdatasets will show with the names of GeoRaster columns on that table. This is usually a short list, since most users will not have more than one or two GeoRaster columns on the same table.

Click on one of the listed subdatasets and then click on [Select] to choose one of the the table/column combination.

The dialog will now show all the rows that contains GeoRaster objects. Note that the subdataset list will now show the Raster Data Table and Raster Id’s pairs.

At anytime the Selection entry can be edited in order to go directly to a known GeoRaster or to go back to the beginning and select another table name.

The Selection data entry can also be used to enter a Where clause at the end of the identification string, e.g.

geor:scott/[email protected],gdal_import,raster,geoid=


See http://www.gdal.org/frmt_georaster.html

for more information.

19.15.3 Displaying GeoRaster

Finally, by selecting a GeoRaster from the list of Raster Data Table and Raster Id’s, the raster image will be loaded into QGIS.

The Select Oracle Spatial GeoRaster dialog can be closed now and next time it opens it will keep the same connection, and will show the same previous list of subdataset making it very easy to open up another image from the same context.

Note: GeoRasters that contains pyramids will display much faster but the pyramids need to be generated outside of QGIS using Oracle PL/SQL or gdaladdo.

The following is example using gdaladdo:

19.15. Oracle GeoRaster Plugin 233

QGIS User Guide, Release 1.8.0

Figure 19.26: Select Oracle GeoRaster dialog gdaladdo georaster:scott/[email protected],georaster\_table,georaster,georid=6 \

-r nearest 2 4 6 8 16 32

This is an example using PL/SQL:

$ sqlplus scott/tiger

SQL> DECLARE gr sdo_georaster;


SELECT image INTO gr FROM cities WHERE id = 1 FOR UPDATE;

END; sdo_geor.generatePyramid(gr, ’rLevel=5, resampling=NN’);

UPDATE cities SET image = gr WHERE id = 1;


19.16 Raster Terrain Analysis Plugin

The Raster Terrain Analysis Plugin can be used to calculate the slope, aspect, hillshade, ruggedness index and relief for digital elevation models (DEM). It is very simple to handle and provides an intuitive graphical user interface for creating new raster layers (See

Figure_raster_terrain_1 ).

Description of the analysis:

• Slope: Calculates slope angle for each cell in degrees (based on first order derivative estimation).

• Aspect: Exposition (starting with 0 for north direction, in degrees counterclockwise).

• Hillshade: Create shaded map using light and shadow to provide a more three-dimensional appearance for a shaded relief map.

• Ruggedness Index: A quantitative measurement of terrain heterogeneity as described by Riley et al. (1999).

It is calculated for every location, by summarizing the change in elevation within the 3x3 pixel grid.

• Relief: Creating a shaded relief map from digital elevation data. Implemented is a method to choose the elevation colors analysing the frequency distribution.

234 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.27: Raster Terrain Modelling Plugin (slope calculation)

19.16.1 Using the plugin

1. Start QGIS and load the gtopo30 raster layer from the GRASS sample location.

2. Load the Raster Terrain Analysis plugin in the Plugin Manager (see Section

Loading a QGIS Core Plugin )

3. Select an analysis method from menu (e.g. Raster → Terrain Analysis → Slope). The Slope dialog appears as shown in

Figure_raster_terrain_1 .

4. Specify an output file path, and an output file type.

5. Click [OK].

19.17 Heatmap Plugin


Heatmap plugin allows to create a heatmap from a point vector map. A heatmap is a raster map showing the density or magnitude of point related information. From the result “hotspots” can easily be identified.

19.17.1 Activate the Heatmap plugin

First this core plugin needs to be activated using the Plugin Manager (see Section

Loading a QGIS Core Plugin ).

After activation the heatmap icon can be found in the Raster Toolbar.

Select from menu View → Toolbars → Raster to activate the Raster Toolbar when it is not yet activated.

19.17.2 Using the Heatmap plugin


Heatmap toolbutton starts the dialog of the Heatmap plugin (see

figure_heatmap_2 ).

The dialog has the following options:

• Input Point Vector dialog: Provides a selection of loaded point vector maps.

19.17. Heatmap Plugin 235

QGIS User Guide, Release 1.8.0

• Output Raster: Using the button you select the folder and the name of the output raster the Heatmap plugin will generate. It is not necessary to give a file extension

• Output Format: Selection of the output format. Although all formats supported by GDAL can be choosen,

GeoTIFF is most in cases the best format to choose.

• Radius: can be used to give the radius in meters or mapunit. When the radius is choosen too small you will not get a nice heatmap. In places where more circles around points overlap eachother the brighter hotspots will occur!

• Decay Ratio: is used to show with which ratio the heat dies out from the center.

– When 0 is given (=minimum) the heat will be concentrated in the centre of given radius and be completely extinguished at the edge.

– When 10 is given (=maximum) the heat is concentrated at the edge and in the centre it is completely extinguished. Higher given values are allowed but have no effect.

– When 1 is given the heat is spread evenly over the whole circle.

– When a negative Decay Ratio is given you will create a Coolmap instead of a Heatmap!

When the Advanced checkbox is checked it will give acces to additional advanced options.

• Row and Column, can be used to change the pixelsize of the output raster. More rows and colums means a smaller pixelsize and the size of the output file will become bigger and processing a bit slower. When doubling the number of rows this will automatically double the size of Columns and the cell sizes will also be halved. The area of the output raster will remain the same!

• Cell Size X and Cell Size Y influence the pixelsize of the output raster and will also change the rows and columns.

The point vector layer may have attribute fields that can be used to create a heatmap:

• Use Radius from Field: the radius set from an attribute field.

• Use Weight from field: the weight factor set from an attribute field.

When the output raster is given, the [OK] button can be used to create a heatmap. The first result is a grey surface that still needs to be given additional treatment to make it a heatmap.

Warning: Changing the raster size properties

When changing the raster size properties, this also changes the resulting output. The hotspot areas will become bigger.

19.17.3 Creating a Heatmap

For the following example, we will use the airports vector point layer from the QGIS sample dataset (see

Sample Data ). Another exellent QGIS tutorial on making heatmaps can be found on





the airports of Alaska are shown.

1. Select the

Heatmap toolbutton. The heatmap dialog starts (see

Figure_Heatmap_2 ).

2. In field Input Point Vector select airpoirt from the list of point layers loaded in current project.

3. In field Output Raster give the name and location using the button of the output raster. Give the output raster file the name heatmap_airports to give an file extension is not necessary.

4. In field Output Format choose GeoTIFF.

5. In the field Radius give 1000000 meters.

6. The original Decay Ratio of 0.1 is fine.

236 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.28: Airports of Alaska

7. Click on [OK] to create and load the new raster map (see

Figure_Heatmap_3 ).

Figure 19.29: The Heatmap Dialog

The result after loading the heatmap is probably not the result which was expected. It is still a grey even surface not showing any variation. First some additional configuration of this layer needs to be done to make the heatmap present itself.

1. Open the properties dialog of layer heatmap_airports (select the layer heatmap_airports, open context menu with right mouse button and select Properties).

2. Select the Symbology tab.

3. Change Color map

4. Press the [Apply] button.

from ‘Grayscale’ to ‘Pseudocolor’.

5. Switch to the Transparency tab and set Global transparency

6. Select [OK]

The final result is shown in

Figure_Heatmap_4 .

to 40%.

19.17. Heatmap Plugin 237

QGIS User Guide, Release 1.8.0

Figure 19.30: The heatmap after loading looks like a grey surface


Figure 19.31: Final result of heatmap created of airports of Alaska

Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

19.18 Road Graph Plugin

The Road Graph Plugin is a C++ plugin for QGIS, that calculates the shortest path between two points on any polyline layer and plots this path over the road network.

Figure 19.32: Road Graph Plugin

Main features:

• calculate path, it’s length and travel time

• optimize by length or by travel time

• export path to a vector layer

• highlight roads directions (this is slow and used mainly for debug purposes and for the settings testing)

As a roads layer you can use any polyline vector layer in any QGIS supported format. Two lines with a common point are considered connected. Please note, it is required to use layer CRS as project CRS while editing roads layer. This is due to the fact that recalculation of the coordinates between different CRS introduce some errors that can result in discontinuities, even when ‘snapping’ is used.

In the layer attribute table the following fields can be used:

• speed on road section — numeric field;

• direction — any type, that can be casted to string. Forward and reverse directions are correspond to the one-way road, both directions — two-way road

If some fields don’t have any value or do not exist — default values are used. You can change defaults and some plugin settings in plugin settings dialog.

19.18.1 Using the plugin

After plugin activation you will see an additional panel on the left side of the main QGIS window. Now make some definitions to the Road graph plugin settings dialog in the menu Vector → Road Graph.

Select a Start and a Stop point in the road network layer and click on [Calculate].

19.18. Road Graph Plugin 239

QGIS User Guide, Release 1.8.0

19.19 Spatial Query Plugin


Spatial Query plugin allows to make a spatial query (select features) in a target layer with reference to another layer. The functionality is based on the GEOS library and depends on the selected source feature layer.

Possible operators are:

• Contains

• Equals

• Overlap

• Crosses

• Intersects

• Is disjoint

• Touches

• Within

19.19.1 Using the plugin

As an example we want to find regions in the Alaska dataset that contain airports. Following steps are necessary:

1. Start QGIS and load the vector layers regions.shp and airports.shp.

2. Load the Spatial Query plugin in the Plugin Manager (see Section

Loading a QGIS Core Plugin ) and click

on the

Spatial Query icon which appears in the QGIS toolbar menu. The plugin dialog appears.

3. Select layer regions as source layer and airports as reference feature layer.

4. Select ‘Contains’ as operator and click [Apply].

Now you get a list of feature IDs from the query and you have several options as shown in

figure_spatial_query_1 .

• Click on the

Create layer with list of items

• Select an ID from the list and click on

Create layer with selected

• Select the ‘Remove from current selection’ in the field And use the result to

• Additionally you can

Zoom to item or display

Log messages



19.20 SPIT Plugin

QGIS comes with a plugin named SPIT (Shapefile to PostGIS Import Tool). SPIT can be used to load multiple shapefiles at one time and includes support for schemas. To use SPIT, open the Plugin Manager from the Plugins menu, check the box next to the toolbar.

SPIT plugin and click [OK]. The SPIT icon will be added to the plugin

To import a shapefile, click on the

SPIT tool in the toolbar to open the SPIT - Shapefile to PostGIS Import

Tool dialog. Select the PostGIS database you want to connect to and click on [Connect]. If you want, you can define or change some import options. Now you can add one or more files to the queue by clicking on the [Add] button. To process the files, click on the [OK] button. The progress of the import as well as any errors/warnings will be displayed as each shapefile is processed.

Tip: Importing Shapefiles Containing PostgreSQL Reserved Words

240 Chapter 19. Plugins

QGIS User Guide, Release 1.8.0

Figure 19.33: Spatial Query analysis - regions contain airports

19.20. SPIT Plugin

Figure 19.34: Using SPIT Plugin to import Shape files to PostGIS


QGIS User Guide, Release 1.8.0

If a shapefile is added to the queue containing fields that are reserved words in the PostgreSQL database a dialog will popup showing the status of each field. You can edit the field names prior to import and change any that are reserved words (or change any other field names as desired). Attempting to import a shapefile with reserved words as field names will likely fail.

19.21 SQL Anywhere Plugin

SQL Anywhere is a proprietary relational database management system (RDBMS) from Sybase. SQL Anywhere includes spatial support including OGC, shape files etc. and built in functions to export to KML, GML and SVG formats.

Figure 19.35: SQL Anywhere dialog (KDE)


SQL Anywhere allows to connect to spatialy enabled SQL Anywhere databases. The Add SQL Anywhere layer dialog is similar in functionality to the dialogs for PostGIS and SpatiaLite.

19.22 Zonal Statistics Plugin

With the

Zonal Statistics Plugin you can analyze the results of a thematic classification. It allows to calculate several values of the pixels of a raster layer with the help of a polygonal vector layer (see

figure_zonal_statistics ). You can

calculate the sum, the mean value and the total count of the pixels that are within a polygon. The plugin generates output columns in the vector layer with a user-defined prefix.


Figure 19.36: Zonal statistics dialog (KDE)

Chapter 19. Plugins

Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF


Table of contents