New version of Serval QGIS plugin

DECEMBER 21, 2020 news plugins qgis raster

Raster selection tools and editing with QGIS expressions.

What’s new?

In the previous version Serval allowed for setting a constant value to a single raster cell at a time. The latest version brings in new raster cells selection tools and new ways of manipulating cells value:

  • QGIS expressions and
  • 3x3 low-pass filter.

Multi-bands rasters are fully supported - each band can be edited separately. Serval is meant to provide a convenient way to modify selected parts of a raster layer. It is not optimized to process entire images - use Raster Calculator for that.

Raster selection tools

In order to modify raster cells values users need to select them first with a line or polygon selection tool. The line selection tool has a configurable width and unit. Selections can also be easily imported/exported from/to a vector map layer.

Multiple selections are allowed and users can add or remove from existing selection using CTRL and SHIFT keys modifiers, respectively.

Selecting raster cells

Modifying rasters with QGIS expressions

In addition to setting a constant value, new cells value might be evaluated using QGIS expressions. Users can build their expressions using cells’ row and column variables, or x and y of cell center point.

In the Serval group of the builder users will find several expression functions for:

  • interpolating raster value from a mesh layer,
  • averaging attribute values from vector layer features intersecting the cell,
  • getting the nearest vector layer feature attribute,
  • interpolating z-value from the nearest 3D linestring feature.

Interpolation on a mesh layer

With the recent QGIS additions it is very easy to create mesh layers. Users can use a mesh layer for raster cell value interpolation. For example, interpolate_from_mesh() function will identify mesh dataset value and return it as a new raster value, optionally only when the value is higher than existing cell value. It is a convenient way for finding an embankment shape on a raster DTM - see pictures below.

Serval QGIS expression builder

Raster values interpolated on a mesh layer

Interpolation on 3D linestrings

Another useful function finds the nearest point on a 3D line feature and interpolate its z-value. It could be used for fine-tuning terrain elevation from a 3D profile line.

For example, if the existing embankment crown needs to be raised by an amount at one of its ends, a user could create a profile line, adjust the vertex elevation in the Vertex Editor and use it for the interpolation.

Raising embankment elevation based on 3D profile line

Creating custom expression functions

In the Expression builder users can define their own functions using other types of vector and raster layers.

Applying 3x3 low-pass filter

For eliminating peak values or local cell values averaging, users can use 3x3 low-pass filter.

Applying low-pass filter

For more details and examples, refer to the plugin’s Manual.

You may also like...

Input, a field data collection app based on QGIS. Input makes field work easy with its simple interface and cloud-based sync. Available on Android and iOS. Screenshots of the Input App for Field Data Collection
Get it on Google Play Get it on Apple store

Posted by Radek Pasiok