Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering QGIS

You're reading from   Mastering QGIS Go beyond the basics and unleash the full power of QGIS with practical, step-by-step examples

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784398682
Length 420 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. A Refreshing Look at QGIS FREE CHAPTER 2. Creating Spatial Databases 3. Styling Raster and Vector Data 4. Preparing Vector Data for Processing 5. Preparing Raster Data for Processing 6. Advanced Data Creation and Editing 7. The Processing Toolbox 8. Automating Workflows with the Graphical Modeler 9. Creating QGIS Plugins with PyQGIS and Problem Solving 10. PyQGIS Scripting Index

Editing data

Vector data layers can be edited within QGIS Desktop. Editing allows you to add, delete, and modify features in vector datasets. The first step is to put the dataset into edit mode. Select the layer in the Layers panel and click on Toggle Editing under Layer. Alternatively, you can right-click on a layer in the Layers panel and choose Toggle Editing from the context menu. Multiple layers can be edited at a time. The layer currently being edited is the one selected in the Layers panel. Once you are in the edit mode, the digitizing toolbar (shown in the following screenshot) can be used to add, delete, and modify features.

Editing data

From left to right, the tools in the digitizing toolbar are as follows:

  • The Current Edits tool allows you to manage your editing session. Here, you can save and rollback edits for one or more selected layers.
  • The Toggle Editing tool provides an additional means to begin or end an editing session for a selected layer.
  • The Save Layer Edits tool allows you to save edits for the selected layer(s) during an editing session.
  • The Add Features tool will change to the appropriate geometry depending on whether a point, line, or polygon layer is selected. Points and vertices of lines and polygons are created by clicking. To complete a line or polygon feature, right-click. After adding a feature, you will be prompted to enter the attributes.
  • Features can be moved with the Move tool by clicking on them and dragging them to the new position.
  • Individual feature vertices can be moved with the Node tool. Click on a feature once with the tool to select it and the vertices will change into red boxes. Click again on an individual vertex to select it. The selected vertex will turn into a dark-blue box. Now, the vertex can be moved to the desired location. Additionally, edges between vertices can be selected and moved. To add vertices to a feature, simply double-click on the edge where you want the vertex to be added. Selected vertices can be deleted by pressing the Delete key on the keyboard.
  • Features can be deleted, cut, copied, and pasted using the Delete Selected, Cut Features, Copy Features, and Paste Features tools.

Snapping

Snapping is an important editing consideration. It is a specified distance (tolerance) within which vertices of one feature will automatically align with vertices of another feature. The specific snapping tolerance can be set for the whole project or per layer. The method for setting the snapping tolerance for a project varies according to the operating system, which is as follows:

  • For Windows, navigate to Settings | Options | Digitizing
  • For Mac, navigate to QGIS | Preferences | Digitizing
  • For Linux, navigate to Edit | Options | Digitizing

In addition to setting the snapping tolerance, here the snapping mode can also be set to vertex, segment, or vertex and segment. Snapping can be set for individual layers by navigating to Settings | Snapping Options. Individual layer snapping settings will override those of the project. The following screenshot shows examples of multiple snapping option choices.

Snapping

Note

There are many digitizing options that can be set by navigating to Settings | Options | Digitizing. These include settings for Feature Creation, Rubberband, Snapping, Vertex markers, and Curve Offset Tool. There is also an Advanced Digitizing toolbar which is covered in Chapter 6, Advanced Data Creation and Editing.

Styling vector data

When you load spatial data layers into QGIS Desktop, they are styled with a random single symbol rendering. To change this, navigate to Layer | Properties | Style.

There are several rendering choices available from the menu in the top-left corner, which are as follows:

  • Single Symbol: This is the default rendering in which one symbol is applied to all the features in a layer.
  • Categorized: This allows you to choose a categorical attribute field to style the layer. Choose the field and click on Classify and QGIS will apply a different symbol to each unique value in the field. You can also use the Set column expression button to enhance the styling with a SQL expression.
  • Graduated: This allows you to classify the data by a numeric field attribute into discrete categories. You can specify the parameters of the classification (classification type and number of classes) and use the Set column expression button to enhance the styling with a SQL expression.
  • Rule-based: This is used to create custom rule-based styling. Rules will be based on SQL expressions.
  • Point displacement: If you have a point layer with stacked points, this option can be used to displace the points so that they are all visible.
  • Inverted polygons: This is a new renderer that allows a feature polygon to be converted into a mask. For example, a city boundary polygon that is used with this renderer would become a mask around the city. It also allows the use of Categorized, Graduated, and Rule-based renderers and SQL expressions.

    The following screenshot shows the Style properties available for a vector data layer:

    Styling vector data

In the preceding screenshot, the renderer is the layer symbol. For a given symbol, you can work with the first level, which gives you the ability to change the transparency and color. You can also click on the second level, which gives you control over parameters such as fill, border, fill style, border style, join style, border width, and X/Y offsets. These parameters change depending on the geometry of your layer. You can also use this hierarchy to build symbol layers, which are styles built from several symbols that are combined vertically.

Styling raster data

You also have many choices when styling raster data in QGIS Desktop. There is a different choice of renderers for raster datasets, which are as follows:

  • Singleband gray: This allows a singleband raster or a single band of a multiband raster to be styled with either a black-to-white or white-to-black color ramp. You can control contrast enhancement and how minimum and maximum values are determined.
  • Multiband color: This is for rasters with multiple bands. It allows you to choose the band combination that you prefer.
  • Paletted: This is for singleband rasters with an included color table. It is likely that it will be chosen by QGIS automatically, if this is the case.
  • Singleband pseudocolor: This allows a singleband raster to be styled with a variety of color ramps and classification schemes.

The following is a screenshot of the Style tab of a raster file's Layer Properties showing where the aforementioned style choices are located:

Styling raster data

Contrast enhancement

Another important consideration with raster styling is the settings that are used for contrast enhancement when rendering the data. Let's start by loading the Jemez_dem.img image and opening the Style menu under Layer Properties (shown in the figure below). This is an elevation layer and the data is being stretched on a black-to-white color ramp from the Min and Max values listed under Band rendering. By default, these values only include those that are from 2 percent to 98 percent of the estimation of the full range of values in the dataset, and cut out the outlying values. This makes rendering faster, but it is not necessarily the most accurate.

Contrast enhancement

Next, we will change these settings to get a full stretch across all the data values in the raster. To do this, perform the following steps:

  1. Under the Load min/max section, choose Min / max and under Accuracy, choose Actual (slower).
  2. Click on Load.
  3. You will notice that the minimum and maximum values change. Click on Apply.
    Contrast enhancement

    Default singleband contrast enhancement (left) and more accurate contrast enhancement (right)

    Tip

    You can specify the default settings for rendering rasters by navigating to Settings | Options | Rendering. Here, the defaults for the Contrast enhancement, Load min/max values, Cumulative count cut thresholds, and the standard deviation multiplier can be set.

Blending modes

The blending modes allow for more sophisticated rendering between GIS layers. Historically, these tools have only been available in graphics programs and they are a fairly new addition to QGIS. Previously, only layer transparency could be controlled. There are now 13 different blending modes that are available: Normal, Lighten, Screen, Dodge, Addition, Darken, Multiply, Burn, Overlay, Soft light, Hard light, Difference, and Subtract. These are much more powerful than simple layer transparency, which can be effective but typically results in the underneath layer being washed out or dulled. With blending modes, you can create effects where the full intensity of the underlying layer is still visible. Blending mode settings can be found at the bottom of the Style menu under Layer Properties in the Layer Rendering section along with the Layer transparency slider. They are available for both vector and raster datasets.

In this example of using blending modes, we want to show vegetation data (Jemez_vegetation.tif) in combination with a hillshade image (Jemez_hillshade.img). Both data sets are loaded and the vegetation data is dragged to the top of the layer list. Vegetation is then styled with a Singleband pseudocolor renderer; you can do this by performing the following steps:

  1. Choose Random colors.
  2. Set Mode to Equal interval.
  3. Set the number of Classes to 13.
  4. Click on Classify.
  5. Click on Apply.

The following screenshot shows what the Style properties should look like after following the preceding steps.

Blending modes

At the bottom of the Style menu under Layer Properties, set the Blending mode to Multiply and the Contrast to 45 and click on Apply. The blending mode allows all the details of both the datasets to be seen. Experiment with different blending modes to see how they change the appearance of the image. The following screenshot shows an example of how blending and contrast settings can work together to make a raster 'pop' off the screen:

Blending modes
You have been reading a chapter from
Mastering QGIS
Published in: Mar 2015
Publisher:
ISBN-13: 9781784398682
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image