qgis 2.0 – kickstart · 2014. 8. 19. · analysis of census data trend mapping what tools are...

104
QGIS 2.0 – Kickstart QGIS Version 2.0 “Dufour”

Upload: others

Post on 08-Feb-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

  • QGIS 2.0 – Kickstart

    QGIS Version 2.0 “Dufour”

  • Table of Contents

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 2

    Table of Contents Table of Contents .............................................................................................................................. 2

    Table of Figures ................................................................................................................................. 5

    Notices .............................................................................................................................................. 6

    Introduction ...................................................................................................................................... 7

    Prerequisites ....................................................................................................................................... 7

    Course Objectives................................................................................................................................ 7

    Training Manual Structure .................................................................................................................. 7

    Getting Help ........................................................................................................................................ 8

    Internet..................................................................................................................................... 8

    Manuals .................................................................................................................................... 8

    Technical Support ..................................................................................................................... 8

    Community Support .................................................................................................................. 8

    Introduction to QGIS ......................................................................................................................... 9

    Key Objectives: ......................................................................................................................... 9

    Introducing QGIS ................................................................................................................................. 9

    What is QGIS? ................................................................................................................................... 10

    Who uses QGIS? ................................................................................................................................ 10

    What tools are available? ................................................................................................................. 10

    QGIS Basics ...................................................................................................................................... 12

    Key Objectives: ....................................................................................................................... 12

    Data Types ........................................................................................................................................ 12

    Geospatial Data Abstraction Library (GDAL/OGR) ........................................................................... 12

    ESRI Shapefile ................................................................................................................................... 14

    Getting Started with QGIS ............................................................................................................... 15

    Key Objectives: ....................................................................................................................... 15

    Starting QGIS for the first time ......................................................................................................... 15

    Setting the QGIS Preferences ............................................................................................................ 16

    What is a QGIS Project? .................................................................................................................... 18

    Navigating the Map .......................................................................................................................... 19

    Bookmarks .............................................................................................................................. 20

    Coordinate Reference Systems ........................................................................................................ 22

    Key Objectives: ....................................................................................................................... 22

    Coordinate Reference Systems (CRS) ................................................................................................ 22

  • Table of Contents

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 3

    Map Grid of Australia 1994 (MGA94) ...................................................................................... 22

    New Zealand Transverse Mercator (NZTM2000) ..................................................................... 23

    Longitude/Latitude (WGS84) ................................................................................................... 23

    Define a CRS for your project ............................................................................................................ 23

    Define a CRS for your layers .............................................................................................................. 23

    On-The-Fly (OTF) Projection .............................................................................................................. 24

    Working with Layers ........................................................................................................................ 25

    Key Objectives: ....................................................................................................................... 25

    Layers ................................................................................................................................................ 25

    Adding Layers ................................................................................................................................... 26

    Adding Vector Layers .............................................................................................................. 26

    Adding Raster Layers (Still to update) ...................................................................................... 27

    Active Layers ..................................................................................................................................... 30

    Reordering Layers ............................................................................................................................. 30

    Saving Layers as a New Format ........................................................................................................ 30

    Grouping Layers ................................................................................................................................ 31

    Layer Editing Sessions ....................................................................................................................... 33

    Creating a Layer............................................................................................................................... 36

    Key Objectives: ....................................................................................................................... 36

    Creating a Layer ................................................................................................................................ 36

    Styles and Labels ............................................................................................................................. 38

    Key Objectives: ....................................................................................................................... 38

    Setting the Style for a layer (Basic) ................................................................................................... 38

    Labelling features on the map .......................................................................................................... 47

    Attribute Data ................................................................................................................................. 53

    Key Objectives: ....................................................................................................................... 53

    Working with Attribute Data via an Attribute Form......................................................................... 53

    Working with Attribute Data via an Attribute Table ........................................................................ 58

    Joining spatial and aspatial data ...................................................................................................... 62

    Attribute Actions ............................................................................................................................... 66

    Editing Map Objects ........................................................................................................................ 69

    Key Objectives: ....................................................................................................................... 69

    Understanding QGIS layer types ....................................................................................................... 69

    Layer Snapping ................................................................................................................................. 69

    What is snapping? ................................................................................................................... 69

    Topological Editing .................................................................................................................. 72

    Drawing New Map Objects ............................................................................................................... 73

    Editing Map Objects ......................................................................................................................... 79

  • Table of Contents

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 4

    Printing ........................................................................................................................................... 83

    Key Objectives: ....................................................................................................................... 83

    What is a Composer? ........................................................................................................................ 83

    Creating a Composer ........................................................................................................................ 83

    Composer Items ................................................................................................................................ 85

    Printing and Exporting ...................................................................................................................... 97

    Managing Existing Composers ......................................................................................................... 98

    Composer Templates ........................................................................................................................ 99

    Plugins .......................................................................................................................................... 101

    Key Objectives: ..................................................................................................................... 101

  • Table of Contents

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 5

    Table of Figures Figure 1 - QGIS Application Window ................................................................................................ 15 Figure 2 - Options Dialog ................................................................................................................. 16 Figure 3 - Project Properties Coordinate Reference System (CRS) tab .............................................. 24 Figure 4 - Layers Panel ..................................................................................................................... 25 Figure 5 - Browser Panel .................................................................................................................. 26 Figure 6 - Active Layer set to Street Trees layer ............................................................................... 30 Figure 7 - Basic Layer Metadata ....................................................................................................... 31 Figure 8 - Stop editing dialog ........................................................................................................... 34 Figure 9 - Symbol Properties dialog (Polygon Layer) ......................................................................... 39 Figure 10 - Symbol Properties dialog (Line Layer) ............................................................................. 41 Figure 12 - Symbol Properties dialog (Point Layer) ........................................................................... 44 Figure 15 - Point label placement options ........................................................................................ 48 Figure 14 - Expression based label dialog ......................................................................................... 49 Figure 16 - Line label placement options .......................................................................................... 50 Figure 16 – Polygon label placement options ................................................................................... 52 Figure 19 - Un-customised Attribute Edit Form ................................................................................ 54 Figure 20 - Layer Properties Fields ................................................................................................... 55 Figure 21 - Attribute Edit Dialog Unique values ................................................................................ 56 Figure 22 - Customised Attribute Edit Form ..................................................................................... 57 Figure 23 - Attribute Table ............................................................................................................... 58 Figure 24 - Snapping Options ........................................................................................................... 70 Figure 30 - Composer Window ........................................................................................................ 84 Figure 31 - Composer Manager........................................................................................................ 98 Figure 32 - Python Plugin Installer ................................................................................................. 102 Figure 32 - Python Plugin Installer – Get More ............................................................................... 102

  • Table of Contents

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 6

    Notices Microsoft, SQL Server, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. All other marks and trademarks are property of their respective holders.

  • Introduction

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 7

    Introduction Welcome to the QGIS 2.0 Kickstart Training Course This course has been designed for user with no or little experience in QGIS, or as a refresher course. The aim of the course is to provide an understanding of the tools used in QGIS to create and edit map features as well as be able to make effective use of tools and procedures associated with printing and plotting. Please feel free to raise any and all questions with the trainer as this course is your opportunity to explore the possibilities QGIS offers.

    Prerequisites No previous GIS software experience is necessary, however a working knowledge of the Microsoft Windows environment is presumed.

    Course Objectives • To provide an overview of core QGIS map production functionality. • To provide a guide to map drawing editing tools, features and support resources. • To provide a range of worked examples that simulates daily GIS related tasks. • To provide an opportunity to ask questions.

    Training Manual Structure This manual is set out in a series of modules. Each module is designed to build on skills learned in previous modules. Each module contains worked “hands-on” exercises. The exercises have been designed to allow you to work through the manual in your own time and have as a ready reference to the tools and procedures.

  • Introduction

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 8

    Getting Help

    Internet The QGIS community uses, as the main method of communication, email mailing lists. There are mailing lists for users, developers, testers, community efforts, etc. The mailing list can be subscribed to by following the instructions on

    http://www.qgis.org/en/community/mailing-lists.html The QGIS community also maintains an Internet Relay Chat (IRC) channel at #qgis on FreeNode.net. The IRC channel is primarily used by developers to chat about new features and bug fixes, although normal users are encouraged to pop in, have a chat, or seek help if needed.

    Manuals QGIS provides user manuals for each release, these manuals can be found at

    http://www.qgis.org/en/documentation/manuals.html The user manuals detail how to use the functionality in QGIS more in depth. The QGIS community is also generating a growing list of How-To guides which can be found at

    http://www.qgis.org/en/documentation.html These guides can be a good source for a quick hit of help on something in QGIS. These documents are a work in progress and may not always be fully up to date. As QGIS is a community based project, if you ever feel that a QGIS resource is not written well enough; doesn't exists; or needs updating, feel free to contact the QGIS team to get ideas with how to help. Contributors are always welcome.

    Technical Support QGIS technical support is available from Digital Mapping Solutions.

    http://support.mapsolutions.co.nz

    Community Support Help can also be found via the QGIS community page

    http://www.qgis.org/en/community.html The Australian QGIS User Group also has a community based website

    https://sites.google.com/site/ausqgis/home

    http://www.qgis.org/en/community/mailing-lists.htmlhttp://www.qgis.org/en/documentation/manuals.htmlhttp://www.qgis.org/en/documentation.htmlhttp://www.qgis.org/en/community.html

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 9

    Introduction to QGIS

    Key Objectives:

    Introduce QGIS

    Learn what QGIS has to offer

    Introducing QGIS QGIS is an open source, community driven Geographic Information System (GIS) that runs on Linux, Windows and Mac OS. The QGIS project began in 2002 with a few programmers and has grown to a functional system with a community of contributors. QGIS has no licensing costs as it is licensed under the GNU General Public License. QGIS is an official project of the Open Source Geospatial Foundation (OSGeo).

    http://www.osgeo.org/ The QGIS project, as a whole, contains multiple sub projects. These sub projects are:

    QGIS Desktop – The main QGIS desktop GIS program.

    QGIS Browser – An easy and fast data viewer that can be used to preview GIS and attribute data of a layer.

    QGIS Server – A WMS (version 1.3) server that uses QGIS Desktop project files.

    QGIS Client – A web based front end for your QGIS Server. Only the QGIS Desktop project is covered in this training course, using the version 2.0 QGIS release. To learn more about QGIS see

    http://qgis.org/.

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 10

    What is QGIS? QGIS is, first and foremost, a GIS or Geographic Information System. A GIS is system designed to capture, store, manipulate, analyse, manage and present all types of geographically referenced data. Systems are typically based on a database concept with the ability to display objects in the correct geographic location plus display the relevant information from linked databases.

    Who uses QGIS? QGIS is now widely used amongst a variety of government and commercial organisations. Also as a free application, it is popular in third world counties and not-for-profit groups.

    Local Government

    Map Creation

    Planning e.g. District Plans

    Asset Management

    Engineers use it for spatial analysis and map and data retrieval Commercial

    Parks Management

    Asset Management

    Mapping client information Mining Companies

    Mapping mines and assets Government

    Analysis of Census Data

    Trend mapping

    What tools are available? QGIS has a standard set of tools and the ability to run custom tools via the plugin system. Plugins can be written in Python and/or C++. Standard Tools:

    A Map Canvas (main map widow) showing the spatial objects.

    Attribute Tables showing the attribute data e.g. like a spreadsheet

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 11

    Layer panel to manipulate layer visibility and order.

    Composer Windows which allow the user to place maps and other objects e.g. scale bars on a page for printing.

    Tool bars, Menus and other user controls for managing spatial data

    Dock windows. The attribute table and Layer panel are examples of dock panels.

  • QGIS Basics

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 12

    QGIS Basics

    Key Objectives:

    Understand data types

    Spatial data formats

    Introduce GDAL and OGR

    Introduce ESRI Shapefiles

    Data Types QGIS doesn’t have its own file format to store data, rather it relies on a range of other open source libraries in order to open and edit a large range of datasets. Datasets, as defined here, means a file, a database, a layer from the Internet etc. When a dataset is opened it is referred to as a layer. QGIS can open three different kinds of data types:

    Vector – these files use geometrical primitives such as points, lines or polygons to represent objects as graphics. For example roads may be represented by lines and building parcels may be represented by polygons.

    Raster – these files represent the data as an array of pixels, typically used for imagery but can also be used to represent vector type data or elevation data.

    Attribute – this files contain no geometry information but rather just plain attribute data. For example rates information with no spatial information.

    Geospatial Data Abstraction Library (GDAL/OGR) QGIS uses the GDAL/OGR library to open and save file formats, so many different files can be viewed and transformed with ease. GDAL is a library for raster geospatial data formats that is released under an open source licence. The OGR Simple Feature Library is an open source library providing read and write access to a variety of vector file formats. This makes up part of the GDAL library. For further information about GDAL/OGR

  • QGIS Basics

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 13

    http://www.gdal.org/

    Supported vector formats:

    Arc/Info Binary Coverage

    Comma Separated Value (.csv)

    DODS/OPeNDAP

    ESRI Personal GeoDatabase

    ESRI ArcSDE

    ESRI Shapefile

    FMEObjects Gateway

    GeoJSON

    Geoconcept Export

    GeoRSS

    GML

    GMT

    GPX

    GRASS Vector 11

    Informix DataBlade

    INTERLIS

    IHO S-57 (ENC)

    MapInfo File

    Microstation DGN

    OGDI Vectors

    ODBC

    Oracle Spatial

    PostgreSQL12

    SDTS

    SQLite

    UK .NTF

    U.S. Census TIGER/Line

    VRT - Virtual Datasource

    X-Plane/Flighgear aeronautical data For more detail on these vector formats

  • QGIS Basics

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 14

    http://www.gdal.org/ogr/ogr_formats.html Supported raster formats:

    Arc/Info Binary Grid

    Arc/Info ASCII Grid

    ERDAS Compressed Wavelets (.ecw)

    GRASS Raster

    GeoTIFF

    JPEG For more detail on these raster formats

    http://www.gdal.org/formats_list.html

    ESRI Shapefile The most commonly used vector format is the ESRI Shapefile and is supported by almost all GIS software. A Shapefile is in fact comprised of several different files. For example, an ESRI Shapefile named Suburbs would appear in the Windows directory as follows: File Type Use Suburbs.shp This file stores the spatial map objects. Suburbs.dbf Used to store the attribute data. Suburbs.shx Index file. Helps programs look information up quickly. Suburbs.prj (optional) Projection information. This file is optional but does help to place map

    objects correctly. Note - If you need to move an ESRI Shapefile data from one location to another via Windows you must be sure to move all the component files.

    http://www.gdal.org/formats_list.html

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 15

    Getting Started with QGIS

    Key Objectives:

    What to do when you first start QGIS

    Understand QGIS projects

    Configuring the QGIS options and preferences

    Starting QGIS for the first time When we first start QGIS we are presented with the main QGIS window ready to begin our GIS project. QGIS will also display a daily tip which can be dismissed once read.

    Figure 1 - QGIS Application Window

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 16

    Before we start working with QGIS we will first run though the main QGIS concepts and user interface elements.

    Setting the QGIS Preferences Like most software, QGIS has Preferences that assist you when using the software. It is advised to set these up first before you start using the software. Once they are setup you rarely have to change the preferences.

    Hands-On – Setting Preferences From the Settings menu, choose “Options…” - the Options dialog will appear…

    Figure 2 - Options Dialog

    We’ll now set some recommended settings for QGIS…

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 17

    General These settings control the general look, feel and operation of QGIS. Most of the settings in this area are set to reasonable defaults. Rendering Controls how QGIS handles rendering of the objects in the Map Canvas; the rendering behaviour; and the rendering quality. Enable “Use render cache where possible to speed up redraws”. Map Tools These options control how certain map tools are handled when used by the user. The main tools options are Identify, Measure tool, Panning and Zooming. In the Identify section set the Mode to Current layer. This will mean the identify tool only selects

    objects on the currently selected layer. Set this option to what you most feel comfortable with as you get used to QGIS.

    In the Identify section Enable “Open feature form, if a single feature is identified”. Digitizing Controls the basic options for how QGIS handles drawing new objects, the line thickness of the drawing line, the default snapping options and how the vertex markers are shown on the objects. In the Snapping section set Default snap mode to “To vertex and segment”. In the Snapping section set Default snapping tolerance to 10 pixels. CRS Controls the Coordinate Reference System (map projection) for new projects, and also for opening layers with no projection information. Set the field “Always start new projects with this CRS” to a map projection that is most suited to

    your area. For the purposes of our training course, set it to “EPSG:28350 –GDA94/MGA Zone 56”

    Enable “Enable ‘on the fly’ reprojection by default”. Enable “Automatically enable ‘on the fly’ reprojection if layers have different CRS” Network Settings to handle using QGIS though a proxy; cache settings for WMS layers. If you are running QGIS behind a proxy then it is recommended to setup these settings as QGIS requires web to download plugins or access webservices. QGIS will also use the system proxy setting by default however in some networks this doesn’t work and must be manually entered here.

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 18

    We have now finished adding our recommended settings. Click the OK button to close the Options dialog.

    What is a QGIS Project? QGIS projects are used to save the current session in QGIS. A QGIS project will save the layers that are open, layer styles, labels, open composer windows, layer order, map canvas state, snapping options; etc. During a QGIS session you may need to leave your workstation or want to store away a record of what is on screen at a point in time. Once you save a project you are able to return to the same session state at a later stage. Just note however, projects do not store layer data. NOTE - QGIS Projects do not store any layer data so you have to save both the layers you are working on and the project if you want to be sure all work is saved.

    Hands-On – Load a Project From the Project menu, choose “Open…” (You can also click the “Open Project” button on the

    toolbar ). Navigate to “C:\QGISTraining\” and select the QGIS Project file named “Perth.qgs” Click the “Open” button. The project will be loaded into QGIS. The project name is displayed in the title bar of the QGIS application window.

    Hands-On – Save Project As From the Project menu, choose “Save As…” (You can also click the “Save Project As” button on

    the toolbar ). Save the project as “training.qgs” to “C:\ QGISTraining\” The project name displayed in the title bar of the QGIS application window has changed to “training”.

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 19

    Navigating the Map Before we get into any more details we will cover the basics of navigating the map and interface. QGIS provides a basic toolbar that includes the navigation tools that you will need to make your way around the map

    Hands-On – Panning the map Select the Pan tool on the toolbar Click and drag the map to pan Panning with the middle mouse button is also a way to change the view. Click in the middle mouse button while moving the mouse to change the view.

    Hands-On – Zooming the map To zoom in: Select the Zoom In tool on the toolbar Left click in the map window to zoom in one step Or Click and drag a rectangle to set the zoom to that area.

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 20

    h To zoom out: Select the Zoom Out tool on the toolbar Left click in the map window to zoom in one step

    Hands-On – Zooming the map Zooming in and out can also be performed using the mouse wheel. Zooming using the mouse wheel is available regardless of the selected map tool. This can be handy if editing a map object and needing to change the zoom without changing the active tool. To zoom in: Scroll the mouse wheel away from you one step To zoom out: Scroll the mouse wheel towards you one step Note: You will notice that QGIS will zoom in to where the mouse is located in the map.

    Bookmarks Bookmarks allow us to save a view of the map and quickly jump back to it if we happen to be somewhere else on the map.

    Hands-On – Creating a new bookmark

    Click the New Bookmark button on the toolbar Edit the name in the opened bookmark manager

  • Introduction to QGIS

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 21

    Change the view using the normal navigation tools

    Click the New Bookmark button on the toolbar Or Click the Add button if the bookmark manager is still open

    Hands-On – Zooming to a bookmark

    Open the bookmark manager using the Show Bookmarks button Double click the bookmark row to change the view Or Single click the row and selected Zoom To The view will be updated to show the selected view.

  • Coordinate Reference Systems

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 22

    Coordinate Reference Systems

    Key Objectives:

    Define and change coordinate reference systems for layers and projects

    Enable on-the-fly reprojections

    Coordinate Reference Systems (CRS) A Coordinate System is a reference system used to define real world locations. QGIS uses coordinate systems or Coordinate Reference Systems (CRS) to manage the geographic space in which objects are drawn relative to each other. There are commonly two types of coordinate systems:

    Geographical coordinates – latitude and longitude

    A projected coordinate system – 2-dimensional Cartesian coordinates A CRS is defined by a map projection and a datum. QGIS has approximately 2700 known CRS definitions stored in a database. Custom CRS are stored in a user database. This is an advanced concept not covered in this guide. For our purposes the three most common coordinate systems are:

    • Map Grid of Australia (GDA94) • New Zealand Transverse Mercator (NZGD2000) • Longitude/Latitude (GDA94)

    Map Grid of Australia 1994 (MGA94) Uses a Universal Transverse Mercator projection and is based on the Geocentric Datum of Australia 1994 (GDA94) using the GRS80 reference ellipsoid. The country is split into a series of zones. MGA94 replaces the older Australian Map Grid 1984 & 1966 (AMG84 & AGM66). There is a shift of approximately 200m in a north easterly direction between the two projections.

    http://www.icsm.gov.au/gda/index.html

    http://www.icsm.gov.au/gda/index.html

  • Coordinate Reference Systems

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 23

    New Zealand Transverse Mercator (NZTM2000) Uses a Universal Transverse Mercator projection and is based on the NZGD2000 datum using the GRS80 reference ellipsoid. The projection applied only to the main New Zealand group and separate projections are available for the offshore islands and its continental shelf. For further information see http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-

    mercator-2000/index.aspx.

    Longitude/Latitude (WGS84) Uses a grid of lines running north to south between the poles i.e. Longitude or X coordinates and east – west around the earth i.e. Latitude or Y coordinates. As a consequence of using lines around a curved surface the lines curve away from each other at the equator and converge at the poles.

    Define a CRS for your project Each new project is started using the default projection. The global default is set with WGS84. This can be changed by choosing Settings > Options under the CRS tab. For the current project you are working on, the CRS may be changed by choosing Settings > Project Properties and selecting the appropriate setting. Alternatively, you can right click any currently loaded layer and choose Set Project CRS from Layer.

    Define a CRS for your layers When a file is loaded into QGIS, the CRS is attempted to be read from the header information in the files. A chooser window will appear and will allow you to check that the CRS is correct. If it is not, you may change the setting there. Otherwise select ok. If there is no CRS you will need to define your choice here to open the file. Alternatively, when the layer is loaded, the CRS may be changed by right clicking on the layer and choosing Set Layer CRS from the menu. A CRS Selector dialog will appear and allow you to set the correct CRS. You can also do this through the Layer Properties dialog under the General Tab. This will not allow you to reproject the data in the layer rather just tell QGIS what the correct projection for the layer should have been if it gets it wrong.

    http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000/index.aspxhttp://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000/index.aspx

  • Coordinate Reference Systems

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 24

    On-The-Fly (OTF) Projection QGIS allows many layers to be overlaid and fitted together regardless of the layer CRS, provided the data covers the same geographic space. This will occur when the on-the-fly reprojection setting is enabled. We have enabled this by default in our settings at beginning of the manual.

    Hands-On – Enabling “on the fly” projections Choose Project > Project Properties… Click the Coordinate Reference System (CRS) tab Tick the checkbox labelled ”Enable ‘on the fly’ CRS transformation”

    Figure 3 - Project Properties Coordinate Reference System (CRS) tab

    Click the OK button to close the Project Properties

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 25

    Working with Layers

    Key Objectives:

    Learn how to add and remove layers

    Manage layer order

    Create groups of layers

    Saving layers

    Active layers

    Layers The concept of layers is fundamental to the operation of QGIS. When we refer to a “layer” we are referring to both the text and graphic data stored in an opened dataset. Layers are generally used to overlay map data which has a common location. Layers provide a convenient method for the manipulation of the data belonging to themes at that location. Many layers can be displayed within QGIS at any one time and analysis carried out within an individual layer or across multiple layers. Layer management in QGIS is done via the Layers panel.

    Figure 4 - Layers Panel

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 26

    Adding Layers There are two ways to open layers in QGIS; via the normal windows file picker; via the Browser Panel (also known as QBrowser).

    Figure 5 - Browser Panel

    Both the normal windows file picker and the Browser will allow you to select multiple layers to load into QGIS.

    Adding Vector Layers

    Hands-On – Add a vector layer (via Windows file picker) Click the layer named “Suburbs” in the Layer Panel - The new layer will be added above this

    selected layer.

    Click the Add vector layer button then select Browse on the next dialog. The normal windows file picker will be displayed. You can filter the type of file being displayed by changing the filter.

    To add a contiguous block of layers, select the first layer, hold down the Shift key, and select the last layer.

    To add multiple layers that are out of sequence, hold down the Ctrl key, select the layers. Navigate to “C:\QGISTraining\Data” and choose the ESRI Shapefile named “Street Trees.shp”

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 27

    Select Open on the windows file picker Select Open on the Add vector layer dialog

    Hands-On – Remove the layer Right click the layer named “Street Trees” in the Layer Panel Choose Remove

    Hands-On – Add a vector layer (via Browser Panel) Click the layer named “Suburbs” in the Layer Panel - The new layer will be added above this

    selected layer. Right Click on an empty space on the toolbar and enable Browser in the popup. The Browser

    Panel will be displayed below the Layer Panel. Navigate to “C:\QGISTraining\Data” and choose the ESRI Shapefile named “Street Trees.shp” Double click or drag the file onto the map canvas to open it. TIP: You can add this folder to your browser favourites by right clicking on the folder and selecting Add as Favourite. Favourites will give you quicker access to folders.

    Adding Raster Layers (Still to update)

    Hands-On – Add a raster layer (via Windows file picker) Click the layer named “Building Footprints” in the Layer Panel - The new layer will be added

    above this selected layer.

    Click the Add raster layer button on the toolbar. The normal windows file picker will be displayed. You can filter the type of file being displayed by changing the filter.

    To add a contiguous block of layers, select the first layer, hold down the Shift key, and select the last layer.

    To add multiple layers that are out of sequence, hold down the Ctrl key, select the layers. Navigate to “C:\QGISTraining\Data” and choose the TIF file named “Perth.tif” Did you notice anything different happen to the map?

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 28

    When the Raster layer was added, any layers underneath the raster layer are masked by a solid white fill for the areas that do not have aerial photography.

    Why is that? Normally there are 3 colour bands in a raster image – Red, Green and Blue. The default setting is to show only 3 colour bands. Fortunately some images can also contain a 4th band that holds transparency information. If the raster layer we added supports a transparent band we can utilise this to correct our map and show the underlying layers. Continued on next page…

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 29

    Double Click the raster layer named “Perth” in the Layer Panel Click the Transparency tab in the layer Properties dialog that appears Choose “Band 4” from the “Transparency Band” drop down list Click the OK button The map should now look fine with the underlying layers showing through for those areas that do not have Aerial Photography.

    NOTE – If the whitespace occurs when you add a raster layer, please check with your GIS Administrator or raster image supplier to see if the raster image supports the 4th band.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 30

    Active Layers Selection and editing tools only work on the active layer. A layer can be set as the Active Layer simply by clicking on it in the layer panel so that it is highlighted. The layer will be changed to bold and underlined text to show that it is active.

    Figure 6 - Active Layer set to Street Trees layer

    Reordering Layers Layers can be re-ordered in the layer panel by dragging them to the appropriate position.

    Saving Layers as a New Format A layer can be saved in its entirety to a new format or just a selection from the layer saved to a new format.

    Hands-On – Save As (to MapInfo Tab Format) Right click the layer named “Street Trees” in the Layer Panel Choose Save As Change the format to MapInfo TAB Browse to “C:\QGISTraining\Data\” and enter the file name “trees” Click the Save button Tick the “Add saved file to map” checkbox Click the OK button A message will be displayed once the Save As has been completed.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 31

    You should now have a layer called “trees” in the Layer Panel. Double click the layer called “trees” in the Layer Panel Click the Metadata tab. The file path, format, etc. will be displayed for the layer.

    Figure 7 - Basic Layer Metadata

    Click the OK button to close the Layer Properties

    Grouping Layers Groups can provide a way to change the visibility of many layers all at once as well as providing some logical structure to the Layer Panel.

    Hands-On – Add a new group Right click the layer named “Building Footprints” in the Layer Panel and choose Add New

    Group. NOTE - We could have actually right clicked anywhere within the Layer Panel to add a new group, but this way we are positioning the new group below the Building Footprints layer.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 32

    Hands-On – Add a new sub -group (aka nested group) Right click the existing Group named “group1” and choose Add New Group

    Hands-On – Rename a group Right click the existing Group named “group1” and choose Rename Rename to “Parks”

    Hands-On – Add layers to a group Drag and drop the existing layers named “Parks Vegetation”, “Parks”, into the Group named

    “Parks” Try changing the visibility of the “Parks” group.

    Hands-On – Remove a group Right click the Group named “sub-group1” and choose Remove NOTE – Be careful when removing Groups as any Layers and/or Sub Groups contained within the group will also be removed.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 33

    Layer Editing Sessions QGIS uses the concept of an editing session when editing the map objects and attribute data associated with a layer. Editing sessions allow you to edit map objects and attribute data in QGIS then save or rollback any edits you have made at the end of the session. An editing session has to be enabled for each layer that is required to be edited before QGIS will let any information be changed. QGIS can have multiple layers in active editing sessions at one time. Most map tools, including editing and selection tools, in QGIS only work on the current active layer. The current active layer refers to the layer that is highlighted in the Layer panel. NOTE – Not all layer formats supported by QGIS allow editing. Some of the layer formats that do allow editing sessions are:

    ESRI Shapefiles

    Microsoft SQL Server Database Tables (if database security allows)

    PostGIS Database Tables

    SpatiaLite Database Tables

    Hands-On – Enabling an editing session for a layer Select the “Road Detail” layer in the Layer Panel so it is highlighted and active. Enable editing on the layer by:

    Clicking the Toggle Editing button on the toolbar or Right-click on the layer in the Layer Panel and select Toggle Editing

    The layer will now be shown to be in edit mode by the display of a pencil icon next to the layer in the Layer panel as well as the vertices on the layers map objects having a red crosses displayed.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 34

    Hands-On – Disabling an editing session for a layer Select the “Road Detail” layer in the Layer Panel so it is highlighted and active. Disable the editing by:

    Clicking the Toggle Editing button on the toolbar or Right-click on the layer in the Layer Panel and select Toggle Editing If you have made changes to the layer you will be presented with a dialog asking you to save or discard you changes…

    Figure 8 - Stop editing dialog

    The pencil icon will be removed from the layer in the Layer Panel.

  • Working with Layers

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 35

    Hands-On – Disabling an editing session for all layers Select the “Road Detail” layer and active its edit session Select the “Suburbs” layer and active its edit session Select the “Street Trees” layer and active its edit session

    Click the Current Edits button on the toolbar Select “Cancel for All Layers” from the menu

  • Creating a Layer

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 36

    Creating a Layer

    Key Objectives:

    Be able to create a new layer

    Understand the requirements for layers

    Understand the importance of a projection In many cases you will be supplied with map data for analysis within QGIS, however, there will be other times where it will be necessary to create your own layer or modify the structure of an existing layer. In this module we will look at the facilities available for layer creation and modification in QGIS.

    Creating a Layer As QGIS doesn't require its own native layer format, we will explore creating an ESRI Shapefile, one of the most common formats in the GIS world. The ESRI Shapefile format only supports three different field types:

    Text Data (Character) - Stores up to 250 alphanumeric characters. You cannot perform arithmetic operations on any numerals in a character field. You should store post code or telephone information in character fields, otherwise leading zeros are dropped.

    Whole Number (Integer) - Stores integers (numbers without a decimal). The range is from -2 billion to +2 billion.

    Decimal Number (Real) - Stores numbers in fixed-point decimal form.

    Hands-On – Create a new ESRI Shapefile From the Layer menu, choose New > New Shapefile Layer… Choose Point for the type Click the “Specify CRS” button Choose “GDA94 / MGA zone 50” and click the OK button Add a new Attribute named “Description” (Text Data, width 250) Add a new Attribute named “Type” (Text Data, width 20) Add a new Attribute named “Height” (Decimal number, width 20, precision 3) Click the OK button

  • Creating a Layer

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 37

    Save to “C:\QGISTraining\Data\ ” with file name “New Trees”

    Hands-On – Modify the Shapefile Structure Ok, we forgot to add an Age attribute to our New Trees Shapefile. We can add the new attribute by… Double click the layer named “New Trees” in the Layer Panel to open the Layer Properties dialog Click the Fields tab

    Click the Toggle Editing button

    Click the New Column button Add the details for the new attribute (name = “Age”, type = Whole Number, width = 4) Click the OK button

    Click the Toggle Editing button Click the Save button to save the changes The Layer Properties dialog should now include the Age attribute Click OK to close the Layer Properties dialog

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 38

    Styles and Labels

    Key Objectives:

    Understand the styling options for a layer

    Label features on the map

    Explore more complex labels

    Setting the Style for a layer (Basic) Each QGIS layer can be styled differently depending on the needs of the map. QGIS contains a range of different rendering engines. Rendering engines control how objects are drawn on the map. The built-in rendering engines include:

    Single Symbol – Renders a single style or Symbol for all objects on the map.

    Categorized – Renders a Symbol for each unique value in a specified table.

    Graduated – Renders a Symbol for each object depending on the range the object falls within a range of values.

    Rule-Based – Renders a Symbol for the object if it meets the supplied rule.

    Point Displacement – Renders a single Symbol for a group of objects that are close together but changes when the user zooms in.

    In this manual we will only cover the Single Symbol renderer. We will cover more advanced styling topic in the QGIS – Discovery training manual.

    Hands-On – Change the style of a Polygon layer Double click the layer named “Wetlands” to open its Layer Properties dialog Click the Style tab The symbol properties dialog will be displayed. Here, you can change all the settings related to the current Symbol including Pen width, colour, type of symbol etc. Continued on next page…

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 39

    Figure 9 - Symbol Properties dialog (Polygon Layer)

    Each Symbol can contain different layers; these are referred to as Symbol Layers. Symbol layers allow you to create custom styles with ease. Select the root item Fill

    Click the Add Symbol Layer button Change the Colour and Fill Style for the new Symbol Layer to be a cross hatch fill pattern with a

    contrasting color.

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 40

    Click the OK button to close the Layer Properties

    Hands-On – Change the style of a Line layer Double click the layer named “Road Detail” to open its Layer Properties dialog Click the Style tab The symbol properties dialog will be displayed. Here, you can change all the settings related to the current Symbol including Pen width, colour, type of symbol etc.

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 41

    Figure 10 - Symbol Properties dialog (Line Layer)

    Select the root item Line

    Click the Add Symbol Layer button

    Move the new Symbol Layer to the bottom using the Move Down button Change the Pen Width for the new Symbol Layer to a value of 1.26 Change the Colour for the new Symbol Layer

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 42

    Select the root item Line Changing the Unit will change if the symbol is rendered using Millimetres or Map Units. Millimetres means the scale of the symbol will vary depending on the millimetres on the screen whereas Map Units means that the symbol is rendered at a constant scale regardless of the current zoom of the map. For example, a line with a 5 meter width will render as 5 meters and may not be visible if the scale of the map is at 1:200(m).

    Changing the Width in the main Style item will scale all the Symbol Layers up or down for the selected Symbol.

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 43

    Changing the Transparency will change how transparent the current symbol is. Changing Colour will change the primary colour in the current symbol. The Advanced drop down box allows you to select a field that contains values for Rotation and Size. Each symbol layer can also have all, or just some, of its properties bound a field or expression using the Data defined properties… Data defined properties are an advanced topic and will not be covered in this manual. The Symbol -> Save in symbol library button allows you to save the symbol with a named style in the style library for later use. Click the OK button to close the Layer Properties and return to the map.

    Hands-On – Change the style of a Point layer Click the checkbox beside the layer named “Street Trees” to make it visible Double click the layer named “Street Trees” to open its Layer Properties dialog Click the Style tab

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 44

    Figure 11 - Symbol Properties dialog (Point Layer)

    Try adding more Symbol Layers, changing the Border Color, Fill Color, Size and Symbol…

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 45

    Click the OK button to close the Layer Properties and return to the map.

    Hands-On – Change the style of a Point layer (using a SVG) Double click the layer named “Street Trees” to open its Layer Properties dialog Click the Style tab Select the first Symbol Layer Choose SVG marker from the Symbol Layer type drop down list. Notice that the Symbol

    Properties dialog changes to show properties related to SVG based symbols. Choose symbol from the SVG Groups panel Pick a tree symbol from the symbols listed (it can be found in the symbol folder) Change the Color and Size properties

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 46

    Click the OK button to close the Layer Properties and return to the map.

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 47

    Labelling features on the map Features on the map can be labelled with text in order to help better explain those features.

    Hands-On – Labelling a Point layer Double click the layer named “Street Trees” to open its Layer Properties dialog Select the Labels tab Tick the Label this layer with check box and select the “comname” field from the drop down

    menu. Note: Advanced labels can be built using the expression button

    Figure 12 - Label Layer Settings dialog

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 48

    Try changing the label settings on the Label Text tab. Options include the following: • Text Style – Change the font family, colour, size of the label. • Buffer – Enable a buffer around the label. • Scale-based visibility – If enabled labels will only be shown between the minimum and

    maximum map scale. • Formatted numbers – If the column used for labels contains decimal numbers enabling this

    option will control the number of decimal places for the number. Try changing the placement settings on the placement tab.

    Figure 13 - Point label placement options

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 49

    Click the OK button to close the Layer Labelling Settings

    Hands-On – Labelling a Line layer First let’s make it a little easier to see the labelling

    Zoom in to street level using the Zoom In tool on the toolbar. Turn on the visibility for the layer named “Contours”. The contours will only be drawn when

    viewing at a close scale. Select the layer named “Contours” in the Layer Panel and open it’s Layer Properties Select the Labels tab

    Tick the Label this layer with check box and select the button so that we can define a custom label.

    Build an expression like: format('Level is \n %1 m', "ELEVATION")

    We use the format() function to build a return string. The \n will add a new line after “Level is”. %1 will be replaced with the value of ELEVATION for each object. A preview of the result can be seen at the bottom

    Figure 14 - Expression based label dialog

    Try changing the label settings on the Label Text tab Try changing the placement settings on the Placement tab. Try using something like Curved and

    Above Line

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 50

    Figure 15 - Line label placement options

    Click the OK button to close the Layer Properties dialog

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 51

    Hands-On – Labelling a Polygon layer Turn off the visibility for the layer named “Contours”. Select the layer named “House Numbers” in the Layer Panel and open it’s Layer Properties Select the Labels tab Tick the Label this layer with check box and select the “noform” field from the drop down menu.

  • Styles and Labels

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 52

    Figure 16 – Polygon label placement options

    Try changing the label settings on the Label Text tab Try changing the placement settings on the Placement tab. Click the OK button to close the Layer Labelling Settings

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 53

    Attribute Data

    Key Objectives:

    Learn how to edit attribute data attached to your map objects

    Learn how to use the attribute edit form

    Learn how to customise the attribute edit form

    Learn how to create layer actions from attribute data

    Learn how to join aspatial data to spatial data

    Working with Attribute Data via an Attribute Form QGIS has the ability to edit the attribute data that is stored with each map object. When editing a feature, QGIS will open an Attributes form in order to let you edit the object’s attribute data. Currently there are three types of forms you are able to define in QGIS for data entry, these are:

    The standard QGIS entry form that can have controls such as dropdowns, file pickers, date pickers; etc.

    A custom form made with Qt Designer which will give more control in layout and controls.

    A custom form with Python logic behind e.g. can be used to connect to a database to fill a combo box with values.

    In this section, and manual, we will cover the standard QGIS entry form.

    Hands-On – View and Edit attribute data for a layer using Identify Features tool Right click the layer named “Street Trees” and choose Toggle Editing to enable editing for the

    layer

    Click the Identify Features tool from the toolbar Click on a tree feature on the map

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 54

    Figure 17 - Un-customised Attribute Edit Form

    The basic attribute editing form is displayed, with each attribute able to be edited via a textbox. Click the OK button to close the Attribute Edit Form

    The standard attributes form can also use a range of extra UI controls to help with editing features. The controls include date pickers, file pickers, drop down boxes, checkboxes etc. Existing unique data in the datasets or a CSV file could be used to fill in the information for the drop down menus.

    Hands-On – Customising the Attribute Edit Form for a layer Double click the layer named “Street Trees” to open its Layer Properties

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 55

    Click the Fields tab A list of available attributes is displayed. Each attribute has a corresponding Edit Widget button. Clicking the Edit widget button for a particular Attribute will open the Attribute Edit Dialog for that attribute. Within that dialog we can decide what type of control the attribute uses for data entry.

    Figure 18 - Layer Properties Fields

    Let’s add a drop down list for the comname attribute Click the Edit Widget button for the “comname” attribute (the button is initially labelled “Line

    Edit” )

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 56

    From the drop down list choose Unique values

    Figure 19 - Attribute Edit Dialog Unique values

    Click the OK button to close the Attribute Edit dialog Let’s add a checkbox for the pwrlines attribute Click the Edit Widget button for the “pwrlines” attribute (the button is initially labelled “Line

    Edit”) From the drop down list choose Checkbox For the checked state type “True” For the unchecked state type “False” Click the OK button to close the Attribute Edit dialog Click the OK button to close the Layer Properties

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 57

    Click the Identify Features tool from the toolbar Click on a street tree feature on the map

    Figure 20 - Customised Attribute Edit Form

    Note that we now have a drop down list for the “comname” attribute, a checkbox for the “perennial” attribute and the “name” attribute is disabled. Click the OK button to close the Attribute Edit Form

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 58

    Working with Attribute Data via an Attribute Table Attribute data can also be edited in QGIS via the Attribute table. The attribute table allows easy browsing of data in a tabular style view, like a spreadsheet. The attribute table can be handy to view or edit many records at once.

    Hands-On – View and Edit attribute data for a layer using the Attribute Table Right click the layer named “Street Trees” and choose Open Attribute table

    Figure 21 - Attribute Table

    The Attribute table is displayed. To edit a cell in the table double click that cell. If there are controls defined for that attribute they will be activated (e.g. drop down lists, checkboxes etc.) Click the Close button to close the Attribute Table Right click the layer named “Street Trees” and choose Toggle Editing to disable editing for the

    layer, Save any changes if asked.

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 59

    Hands-On – Update a column using the field calculator Sometimes it might be required to update existing values or create a new field with set values in the attribute table. This can be achieved using the field calculator. Right click the layer named “Street Trees” and choose Open Attribute table

    Enable editing on the layer using the Toggle Editing button

    Click the Open Field Calculator button

    Enter a new field in Output field name. Call it “cond_score” We are going to translate the condition name into a score rating and will use an expression to do this. Expand the Conditionals section

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 60

    Find and double click on the CASE entry It will enter enter the following expression into the text area

    CASE WHEN condition THEN result END

    Add three more WHEN condition THEN result sections so you expression looks like the following

    You will notice we also added an ELSE section. If none of the when conditions are matched this will be the final result. We now need to replace the condition and result sections. Delete the word condition from the first WHEN but leave the text cursor there Find and expand the Field and Values section Double click on the field name cond_desc Press the = button or type it on your keyboard Click Load all unique values Double click on ‘Good’ Replace the result part of the WHEN with 1 The first when expression should now look like this:

    WHEN "cond_desc" = 'Good' THEN 1 Repeat the process for Fair, Poor, Dead Use -1 for ELSE result The final expression will look like this:

    CASE WHEN condition THEN result WHEN condition THEN result WHEN condition THEN result WHEN condition THEN result ELSE result END

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 61

    This expression will check each WHEN block and return the result after the THEN. Using this we can create a number based column from condition names. Press OK Scroll to the far right of the attribute table

    CASE WHEN "cond_desc" = 'Good' THEN 1 WHEN "cond_desc" = 'Fair' THEN 2 WHEN "cond_desc" = 'Poor' THEN 3 WHEN "cond_desc" = 'Dead' THEN 4 ELSE -1 END

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 62

    The new column is now added to the table and updated with the values from the expression

    Click the Save Edits button to save the layer data.

    Joining spatial and aspatial data At times it is required to join non-spatial, also known as aspatial, data e.g. census information, to a spatial data. Joining allows non-spatial information to be associated with spatial objects which can then be visualised in QGIS.

    Hands-On – Joining a layer of Asset Inspection Points to a csv file of Replacement costs Let’s add in an ESRI Shapefile layer containing Asset Inspection points Navigate to the training data folder in the Browser dock Drag and drop “Asset_Inspection.shp” into the map canvas. Right click on the Asset Inspection layer and select Zoom to Layer Extent At this stage, if we use the Identify Features tool on one of the Asset Inspection points on our map, we will only see the values in the Asset Inspection layer. Let’s add in a CSV Text File la yer containing some extra information

    Click the Add delimited text layer button then select Browse on the next dialog. The normal windows file picker will be displayed.

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 63

    Navigate to “C:\QGISTraining\Data\” and choose the CSV file named Asset_Inspection_Data.csv”

    Select Open on the windows file picker Select CSV Select No geometry (attribute only table)

    Select OK At this stage, we can right click on the “Asset Inspection Data” layer and choose Open Attribute Table to see all the some extra asset inspection information for the layer. However it is not able to be viewed on the map yet. We need to join the two layers… Double click the layer named “Asset Inspection” Click the Joins tab

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 64

    Click the button to add a new join Set the Join Layer to “ncs_rg_building_consents” Set the Join field to “consent_id” Set the Target field to “Consent_No”

    Click the OK button to close the Add vector join dialog Click the Apply button (we use Apply in this case as we do not want to close the Layer Properties)

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 65

    Click the Fields tab. Notice how all the attributes from the csv file are now displayed.

    Click the OK button to close the Layer Properties

    Click the Identify Features tool from the toolbar Click on an Asset Inspection point on the map

    All the attributes are displayed from the csv file as well as the “Category” attribute from the ESRI Shapefile. Note: The joined fields cannot be edited at this stage.

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 66

    Attribute Actions Attribute actions allow you to perform an action when viewing information for feature on the map. These actions can include such things as:

    Launching a custom Python script (Python is the programming language used in QGIS)

    Opening a website

    Loading an application

    Opening an image

    Preforming other actions inside QGIS

    Hands-On – Add an action to open a web page Open to the Wikipedia article for the name of the selected street tree Double click the layer named “Street Trees” Click the Actions tab In the Action Properties section, select Open from the Type drop down list The type of action to be invoked i.e. what kind of command will be used to run the action.

    Windows – Runs the action in a windows command line

    Python – Runs the action as a Python code block

    Unix – Runs the action in a Unix command line (Only on Linux)

    Mac – Runs the action in a Mac OS X command line (Only on Mac OS X)

    Open – Runs the system default open command On windows the most common action types are Python and Open. For the Name, type “Search Wiki” For the Action, type in the following URL to the Wikipedia search page…

    http://en.wikipedia.org/wiki/Special:Search/

    Now we just need to add the tree name on the end of the URL to have the correct web page open… In the drop down list beside the Insert Field button, select the “botname” field

    Click the Insert field button . That will add the valuation number form our data onto the end of the URL we typed in for the action.

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 67

    Notice that the expression part is inside [% {expression %]. This is a convention used though out QGIS to represent an expression in a block of text. Only what is inside the [% {expression %] block will get run as an expression the rest is just plain text.

    Click the Add to action list button . Click the OK button to close the Layer Properties The Identify Results window lists the actions that have been assigned to the layer and its features.

    Click the Identify Features tool from the toolbar Click on a Street Tree point on the map Right click in the attribute form and select Search Wiki

    The action will open the default web browser and search Wikipedia for the given name of the tree.

  • Attribute Data

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 68

    Hands-On – Using the Run Feature Action tool An alternative way of running an action is to use the Run Feature Action tool on the toolbar

    Click the down arrow button immediately beside the Run Feature Action button on the toolbar

    Select “Search Wiki” from the resulting drop down list Click on a building consent point on the map. The web page is launched directly. NOTE - The action will only be run for the feature directly under where you clicked on the map. If there are multiple features at that location, only the first one is used.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 69

    Editing Map Objects

    Key Objectives:

    Learn how to draw new map objects

    Learn how to edit your map objects quickly and efficiently

    Learn how to edit attribute data attached to your map objects

    Understanding QGIS layer types QGIS can only store/read one object type per layer e.g. point, polygon, line, meaning you cannot store a point object in the same layer as a line object. This also means that some of the editing tools will differ depending on the layer type you are working with. A quick way to tell what kind of map object the layer is using is to look at the icon next to the layer name in the Layer panel…

    Points

    Lines

    Polygons

    Layer Snapping

    What is snapping? When digitising, or editing vector data, there is a need to connect objects together in some way. In QGIS it is possible to connect one object to another by snapping at least one node in one object to one node in another object. Of course multiple nodes can be also be snapped. This will ensure that nodes placed on a common boundary for two adjacent objects will be at the same location. That is, snapped together. The Snap tool will show when our cursor is being snapped to an existing node. See below.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 70

    In the image above we can see that the red dotted line, the line being drawn, has snapped to existing line once it comes within the set tolerance. A small purple cross shows the proposed snapping location. QGIS will let you snap objects to existing nodes on a line or along the segment of a line

    Hands-On – Activating Snap Mode for a layer From the Settings menu, choose “Snapping Options…” - the Snapping Options dialog will

    appear…

    Figure 22 - Snapping Options

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 71

    The snapping options dialog lists all the layers and the snapping options for each layer. Click the check box to enable snapping for that layer. Set the options as required:

    Mode: The mode that control how the snapping is done. To vertex will only snap to nodes; To segment will snap along the line segment of the object; To vertex and segment will snap the object to both the nodes and along the segment.

    Tolerance: The distance tolerance for the snap.

    Units: The units of the tolerance. Recommended setting is pixels as it will allow the same snapping at any zoom level.

    Avoid Int (Avoid Intersections): When drawing a polygon over another polygon the layer with this option activated the object will automatically cut the object that it overlaps in order to avoid intersecting objects.

    Enable topologic editing: When moving nodes that have been snapped the other connected objects will also be moved to preserve the snap i.e. they will stay joined. Recommended setting is to leave this off until needed.

    Enable snapping for Property Boundaries and Road Detail. Use a Tolerance of 10 pixels. We will

    use this in the next section. Click the OK button to close the Snapping Options

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 72

    Topological Editing With topological editing enabled using the Node Tool to move a node or segment of an object will result in all connecting segments and nodes also being moved at the same time in order to preserve connectivity.

    Moving a node with topological editing on: The image below shows a node being moved with topological editing enabled. Notice the blue line being dragged also drags the other lines. The red lines show the new locations of the joined lines.

    Moving a node with topological editing off: Notice now the moving the blue line doesn't affect the other line segments.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 73

    Drawing New Map Objects

    Hands-On – Adding point objects to the Trees layer Right click the layer named “New Trees” and choose Toggle Editing. The layer should now have a

    Pencil icon in front of the layer name indicating it is editable.

    Click the Add Feature tool on the toolbar. Click once on the map at the desired location for the new tree object Enter any attributes in the Attributes dialog…

    Click the OK button to close the Attributes dialog You should now have a new map object representing a tree. You can use the Identify Features tool to see any attributes for the tree you have just added. Add a 4 or 5 more trees to your map…

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 74

    Right click the layer named “New Trees” and choose Toggle Editing. Click the Save button to save the changes you made

    Hands-On – Adding line objects to the Roads Details Right click the layer named “Road Detail” and choose Toggle Editing. The layer should now have

    a Pencil icon in front of the layer name indicating it is editable.

    Click the Add Feature tool on the toolbar. Hover over the start point. Because we have enabled snapping for the Property Boundaries layer

    a purple marker will be shown on the location where the first point will be create

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 75

    Click once on the map at the desired location for the start of the line object. A dotted line shows the line which has not be completed yet.

    Continue single clicking for each node of your line. You will notice the line turn solid once it has

    been drawn.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 76

    To finish the line right click after you have placed you last node. Enter any attributes in the Attributes dialog… Click the OK button to close the Attributes dialog You should now have a map object representing a new section of road details. You can use the Identify Features tool to see any attributes for the road detail line you have just added.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 77

    Right click the layer named “Road Details” and choose Toggle Editing. Click the Save button to save the changes you made

    Hands-On – Adding Polygon objects to the Native Forests layer Right click the layer named “Wetlands” and choose Toggle Editing. The layer should now have a

    Pencil icon in front of the layer name indicating it is editable.

    Click the Add Feature tool on the toolbar. Left click once on the map at the desired location for the start of the wetland polygon object Continue single left clicking to add a new node to your polygon Right click when finished to end the drawing operation. Note. You can see the polygon to be added below in dark red. The yet to be finished section is outlined with a dashed line and semi-transparent fill.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 78

    Enter any attributes in the Attributes dialog… Click the OK button to close the Attributes dialog You should now have a new map object representing a new area of wetlands. You can use the Identify Features tool to see any attributes for the wetland polygon you have just added.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 79

    Right click the layer named “Wetlands” and choose Toggle Editing. Click the Save button to save the changes you made

    Editing Map Objects

    Hands-On – Deleting a Tree point object on the map Right click the layer named “Street Trees” and choose Toggle Editing. The layer should now have

    a Pencil icon in front of the layer name indicating it is editable.

    Click the Select Single Feature tool on the toolbar. Click the tree object on the map that you wish to delete. The object will be highlighted to show it

    is selected

    Click the Delete Features tool on the toolbar Click the OK button on the Delete features dialog to confirm the deletion.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 80

    Right click the layer named “Street Trees” and choose Toggle Editing. Click the Save button to save the changes you made

    Hands-On – Moving a Tree point object on the map Right click the layer named “Street Trees” and choose Toggle Editing. The layer should now have

    a Pencil icon in front of the layer name indicating it is editable.

    Click the Move Feature tool on the toolbar. Click the map object and while holding down the left mouse button, drag the map object to the

    new location. A shaded object will be shown under the mouse cursor whilst the object is being moved.

    Release the left mouse button to complete the move. Right click the layer named “Trees” and choose Toggle Editing. Click the Save button to save the changes you made

    Hands-On – Reshaping a building footprint polygon object on the map Right click the layer named “Building Footprints” and choose Toggle Editing. The layer should

    now have a Pencil icon in front of the layer name indicating it is editable.

    Click the Node tool on the toolbar. The cursor will change to a cross hair to let you select the nodes of an object

    When the Node Tool is activated, the nodes of an individual object can be moved, deleted or added. The Node Tool also supports moving and deleting multiple nodes of an object Click the object on the map. Red squares around each node will appear.

    For polygons, click on the boundary of the object.

    For lines, click on the line.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 81

    Select a node by left clicking with the mouse.

    You can select multiple nodes by clicking and dragging a rectangle over the nodes that you need to move.

    Reshape the feature using the following methods:

    To move a node(s) - click it and drag a node to the desired location. The line segments connected to the node are moved to a new position.

    To add a node - double click anywhere on a line segment. A new node will be added. The new node can be deleted or moved, just as you would any node.

    To delete a node(s) - left click on the node and press the Delete key. Polygons or lines in QGIS cannot be fully deleted using this method, a polygon must always contain at least three nodes and lines must at least contain two nodes.

  • Editing Map Objects

    User Notes

    Copyright © 2014 Digital Mapping Solutions

    P a g e | 82

    Click the Node tool on the toolbar to finish node editing. You should now have a reshaped map