Related Plugins and Tags

QGIS Planet

2.5.3 - Fancy Flamingo


🐛 Bug Fixes

  • Fix Bluetooth scanning on devices running Android >= 12
  • Fix multi-line text editor widget
  • Fix wrong magnetic variation value with internal GNSS devices

MovingPandas v0.12 released!

The latest v0.12 release is now available from conda-forge.

This release contains some really cool new features, including:

  • New function to add an acceleration column #253
  • We have further improved our repo setup by adding an action that automatically creates and publishes packages from releases, heavily inspired by the work of the GeoPandas team.
  • Last but not least, we’ve created a Twitter account for the project. (And might soon add a Mastodon account as well.)

As always, all tutorials are available from the movingpandas-examples repository and on MyBinder:

If you have questions about using MovingPandas or just want to discuss new ideas, you’re welcome to join our discussion forum.

QField 2.5 is here, reaching new heights

Our ninjas have been so busy that less than a month after we released QField 2.4, we find ourselves with so many new features we simply can’t wait any longer to present to you the latest version of QField: 2.5 “Fancy Flamingo 🦩”.

Exciting new features

QField’s main new feature of this 2.5 release cycle is its brand new elevation profiling functionality which has been added to the measuring tool. Users are now able to dynamically build and analyze elevation profiles wherever they are – in the field or on their desktop – by simply drawing paths onto their maps and projects.

This is a great example of QField’s capability at bringing the power of QGIS through a UI that keeps things simple and avoids being in your way until you need it. Oh and while we’re speaking of the measuring tool, check out the new azimuth measurement!

This new version also brings multi-column support to feature forms. QField now respects the number of columns set by users in the attributes’ drag and drop designer while building and tweaking projects in QGIS. The implementation will take into account the screen availability and on narrow devices will revert to a one-column setup. Pro tip: try to change the background color of your individual groups to ease understanding of the overall feature form.

Another highlight of this release is a brand new screen lock action that can be triggered through QField’s main menu found in the side dashboard or in the map canvas menu shown when long pressing on the map itself. Once activated, QField will become unresponsive to touch and mouse events while keeping the display turned on. When locked, QField also hides tool buttons which results in a more complete view of the map extent.

Stability improvements

As with every release, our ninjas have been spending time hunting nasty bugs and improving stability and QField 2.5 is no exception. In particular, the feature form should feel more reliable and even more polished.

2.5.2 - Fancy Flamingo


🐛 Bug Fixes

  • Feature form fixes and optimizations
  • Nicer in-app QFieldCloud registration process

2.5.1 - Fancy Flamingo

🐛 Bug fixes

  • Fix occasional crash when activating the measuring tool
  • Further feature form stability fixes

View and track changes in QGIS

With the recent changes to the Mergin Maps plugin for QGIS, you can visualise the local changes before synchronising your data.

Have you ever been in the situation when, after making a lot of changes in your Mergin Maps project, you hesitate to press Sync button because you are not sure that all required changes are made or afraid that some unwanted edits were introduced? Or maybe you need to review the work done and see what actually have changed between two versions? If the answer to any of these questions is “yes” then you will like the changes visualisation functionality we introduced in the 2022.4 version of the Mergin Maps plugin for QGIS.

Changes visualisation functionality comes handy in two use-cases: revising local changes made in the Mergin Maps project before syncing them with the server and getting a list of changes between two versions of the project. Let’s take a closer look at this feature.

Local changes visualisation

While working with Mergin Maps project, the user can at any time revise their current changes made locally. First, make sure that all your layer’s edits are saved (committed) as currently viewing of the unsaved changes is not supported. Then right-click on any vector layer and select “Show Local Changes” entry in the context menu.

Accessing local changes from context menu

Accessing local changes from context menu

This will open the Changes Viewer dialog. Each vector layer with local changes has its own tab in the Changes Viewer dialog, the name of the tab matches the layer name and also contains information about the number of changes in this specific layer. Local changes are shown on the map and in the tabular form, to distinguish different types of edits a following color codes are used: inserts (new features) are green, edits orange and deletions red. It is possible to enlarge or reduce the size of the map and table by dragging the splitter between them, splitter position is applied to all tabs and will be saved and reused on the further dialog calls.

Features added, deleted and modified in map and tabular views

Features added, deleted and modified in map and tabular views

Map canvas in the Changes Viewer dialog supports basic operations like panning as well as zooming in and out. By default, all project layers are shown on the map to provide better context, but it is possible to toggle their visibility by unchecking the “Toggle Project Layers” button in the toolbar above the map. When this button is unchecked, only changes from the current vector layer are shown.

If, after some panning/zooming, you need to return to the extent where all changes are visible — press “Zoom Full” button. Also, it is possible to select a specific feature(s) in the table below map and zoom to them by clicking the “Zoom To Selection” button. Finally, changes can be added as a new memory layer to the current project. To do so, click “Add to project” button and choose one of the options: add changes from the current layer or add all changes from all layers. For each changed layer, a new memory layer will be added to the current project. These changes layers will preserve the same color coding for features and attribute table as used in the Changes Viewer dialog. Please note, that these layers should be manually removed from the project before the sync, unless it is your intention to make them a part of your Mergin Maps project. Another way to revise local changes is to open Changes Viewer from the Project Status dialog by clicking “View Changes” button.

Mergin Maps Processing tools

Sometimes one may want to export local changes as a vector layer and save that file for further usage. Of course, this can be done with the help of Changes Viewer dialog, but it is time-consuming, especially when the Mergin Maps project has many layers or if there is a need to check local changes in several projects. To cover this use-case, we also provide “Extract local changes” tool. This tool is a part of the Mergin Maps QGIS plugin and can be found under the “Mergin Maps” group in the Processing Toolbox.

Mergin Maps Processing tools to create changeset

Mergin Maps Processing tools to create changeset

In the tool dialog you need to specify a directory with your Mergin Maps project, select a layer of interest either choosing from available layer or selecting a GeoPackage file in the project directory and layer in this file.

Processing tool to extract local changes

Processing tool to extract local changes

An output layer containing local changes will be created as a temporary or regular layer and added to the current project. This layer will have the same styling (both for features and attribute table) as the layers produced by Changes Viewer dialog.

Result of the local change processing tool

Result of the local change processing tool

The “Create diff” tool comes handy when you need to revise the changes between two versions of the layer in the Mergin Maps project. This tool is also a part of the Mergin Maps QGIS plugin, and it is implemented as a Processing algorithm. The “Create diff” tool can be found under the “Mergin Maps” group in the Processing Toolbox.

The tool dialog is quite similar to the “Extract local changes” tool dialog. Fill in input values: directory of your Mergin Maps project, layer of interest, start and end version numbers. Finally, specify location of the output vector layer or leave the field empty if you want it as a temporary layer in your current project. After clicking “Run” the tool will query the server for information and generate a vector layer containing all changes made between specified layer versions. For example, if some field value was changed in one version and then the same field was changed again in another version, then only the last change will be shown in the output changes file.

This feature is an another step in our ongoing efforts to create an easy-to-use tool for collaborative data collection and data management. If you need help or want to share your experience with Mergin Maps QGIS plugin, please join us in the community chatroom, and we will be happy to hear your thoughts.

2.5.0 - Fancy Flamingo

🚀 New features


  • Elevation profiling of terrain and layers (#3501)
  • Multi-column support in feature form (#3518)
  • Measuring tool display azimuth values (#3503)
  • Locked screen mode to avoid accidental touches while QField is in your pocket (#3507)
  • Customize number of items shown in the feature form’s relation editor widget (#3520)


  • Handling of feature form group’s background color
  • Improved viewing resolution of GeoPDFs and georeferenced PDFs datasets
  • Font sizing on Windows, Linux, and MacOS
  • NULL state for the feature form’s checkbox widget
  • New feature handling of default values improved to match QGIS behavior

🐛 Bug fixes

  • Fix default value relying on positioning variables updated on feature edits
  • Fix external GNSS receiver’s ellipsoidal elevation regression
  • More feature form-related bugs addressed, simply too many to list

Plugin Update October 2022

The QGIS plugin repository currently lists 1728 plugins and the list keeps on growing. October has been busy with 15 new plugins. It can be challenging to stay up to date.

Our monthly plugin update is meant to provide you a quick overview of the newest plugins. If any of the names or short descriptions piques your interest, you can find the direct link to the plugin page in the table below the screenshot.

Query Tool
The plugin is used to extract clusters (Tie) on shapefile issue for the Pavemetrics inspections systems.
NextGIS IdentifyPlus
Extended identify tool. Show photos and other attachments stored in your Web GIS right in QGIS. Developed by NextGIS.
MapBiomas Collection Official
This plugin lets you add the anual land use and land cover maps from the MapBiomas Project ( as a collection of WMS layer.
FLINTpro Datacheck
This plugin is designed for FLINTpro users to easily check the compatibility of data for uploading to FLINTpro.
Selection Sets Reloaded
Plugin for saving and loading selection sets for layers.
Deepness: Deep Neural Remote Sensing
Inference of deep neural network models (ONNX) for segmentation, detection and regression
Create points on arcs’ intersection
The plugin creates a new layer with points on arcs’ intersection within the same layer
Download data from IBGE
This plugin downloads data from IBGE
This is a plugin to interract with the GMSH mesh generator (see
Replace Geometry
Replaces a geometry keeping the attributes unchanged
SensorThings API
The plugin enables QGIS to access dynamic data from sensors, using SensorThings API protocol (
Fast Field Filler
The plugin was created to quickly fill in the fields in the attribute table.
Nearest Neighbor Method for Linear Features (NNMLF)
This plugin estimates the spatial distribution pattern of linear features.
NDFF Connector Plugin
This connector uses the NDFF-Connector library to create all needed configuration and settings to connect to the NDFF api, to upload Observations/Waarnemingen
Zone Label
This plugin allows to split and manually label rectangular areas.

SLYR Update — November 2022

Our SLYR tool is the complete solution for full compatibility between ArcMap, ArcGIS Pro and QGIS. It offers a powerful suite of conversion tools for opening ESRI projects, styles and other documents directly within QGIS, and for exporting QGIS documents for use in ESRI software.

A lot has changed since our last SLYR product update post, and we’ve tons of very exciting improvements and news to share with you all! In this update we’ll explore some of the new tools we’ve added to SLYR, and discuss how these tools have drastically improved the capacity for users to migrate projects from the ESRI world to the open-source world (and vice versa).

ArcGIS Pro support

The headline item here is that SLYR now offers a powerful set of tools for working with the newer ArcGIS Pro document formats. Previously, SLYR offered support for the older ArcMap document types only (such as MXD, MXT, LYR, and PMF formats). Current SLYR versions now include tools for:

Directly opening ArcGIS Pro .lyrx files within QGIS

LYRX files can be dragged and dropped directly onto a QGIS window to add the layer to the current project. All the layer’s original styling and other properties will be automatically converted across, so the resultant layer will be an extremely close match to the original ArcGIS Pro layer! SLYR supports vector layers, raster layers, TIN layers, point cloud layers and vector tile layers. We take great pride in just how close the conversion results are to how these layers appear in ArcGIS Pro… in most cases you’ll find the results are nearly pixel perfect!

In addition to drag-and-drop import support, SLYR also adds support for showing .lyrx files directly in the integrated file browser, and also adds tools to the QGIS Processing Toolbox so that users can execute bulk conversion operations, or include document conversion in their models or custom scripts.

ArcGIS Pro map (mapx) and project (aprx) conversion

Alongside the LYRX support, we’ve also added support for the ArcGIS Pro .mapx and .aprx formats. Just like our existing .mxd conversion, you can now easily convert entire ArcGIS Pro maps for direct use within QGIS! SLYR supports both the older ArcGIS Pro 2.x project format and the newer 3.x formats.

Export from QGIS to ArcGIS Pro!

Yes, you read that correctly… SLYR now allows you to export QGIS documents into ArcGIS Pro formats! This is an extremely exciting development… for the first time ever QGIS users now have the capacity to export their work into formats which can be supplied directly to ESRI users. Current SLYR versions support conversion of map layers to .lyrx format, and exporting entire projects to the .mapx format. (We’ll be introducing support for direct QGIS to .aprx exports later this year.)

We’re so happy to finally provide an option for QGIS users to work alongside ArcGIS Pro users. This has long been a pain point for many organisations, and has even caused organisations to be ineligible to tender for jobs which they are otherwise fully qualified to do (when tenders require provision of data and maps in ArcGIS compatible formats).

ArcGIS Pro .stylx support

Alongside the other ArcGIS Pro documents, SLYR now has comprehensive support for reading and writing ArcGIS Pro .stylx databases. We’ve dedicated a ton of resources in ensuring that the conversion results (both from ArcGIS Pro to QGIS and from QGIS to ArcGIS Pro) are top-notch, and we even handle advanced ArcGIS Pro symbology options like symbol effects!

Take a look below how even very advanced ArcGIS Pro style libraries convert beautifully to QGIS symbol libraries:

ArcMap Improvements

While we’ve been focusing heavily on the newer ArcGIS Pro formats, we’ve also improved our support for the older ArcMap documents. In particular, SLYR now offers more options for converting ArcMap annotation layers and annotation classes to QGIS supported formats. Users can now convert Annotation layers and classes directly over to QGIS annotation layer or alternatively annotation classes can be converted over to the OGC standard GeoPackage format. When exporting annotation classes to GeoPackage the output database is automatically setup with default styling rules, so that the result can be opened directly in QGIS and will be immediately visualised to match the original annotation class.

Coming soon…

While all the above improvements are already available for all SLYR license holders, we’ve got many further improvements heading your way soon! For example, before the end of 2022 we’ll be releasing another large SLYR update which will introduce support for exporting QGIS projects directly to ArcGIS Pro .aprx documents. We’ve also got many enhancements planned which will further improve the quality of the converted documents. Keep an eye on this blog and our social media channels for more details as they are available…

You can read more about our SLYR tool at the product page, or contact us today to discuss licensing options for your organisation.


Creating circular insets and other fun QGIS layout tricks

Thanks to the recent popularity of the “30 Day Map Challenge“, the month of November has become synonymous with beautiful maps and cartography. During this November we’ll be sharing a bunch of tips and tricks which utilise some advanced QGIS functionality to help create beautiful maps.

One technique which can dramatically improve the appearance of maps is to swap out rectangular inset maps for more organic shapes, such as circles or ovals.

Back in 2020, we had the opportunity to add support for directly creating circular insets in QGIS Print Layouts (thanks to sponsorship from the City of Canning, Australia!). While this functionality makes it easy to create non-rectangular inset maps the steps, many QGIS users may not be aware that this is possible, so we wanted to highlight this functionality for our first 30 Day Map Challenge post.

Let’s kick things off with an example map. We’ve shown below an extract from the 2032 Brisbane Olympic Bid that some of the North Road team helped create (on behalf of SMEC for EKS). This map is designed to highlight potential venues around South East Queensland and the travel options between these regions:

Venue Masterplan Brisbane 2032 Olympics
Venue Masterplan for 2032 Olympic Games, IOC Feasibility Assessment – Olympic Games, Brisbane February 2021

Circles featured heavily in previous Olympic bid maps (such as Budapest) where we took our inspiration from. This may, or may not, play a part in using the language of the target map audience – think Olympic rings!

Budapest Olympics 2024 MasterplanBudapest Olympics 2024 Masterplan


Step by Step Guide to Creating a Circle Inset

Firstly, prepare a print layout with both a main map and an inset map. Make sure that your inset map is large enough to cover your circular shape:

From the Print Layout toolbar, click on the Add Shape button and then select Add Ellipse:

Draw the ellipse over the middle of your inset map (hint: holding down Shift while drawing the ellipse will force it to a circular shape!). If you didn’t manage to create an exact circle then you can manually specify the width and height in the shape item’s properties. For this one, we went with a 50mm x 50mm circle:

Next, select the Inset Map item and in its Item Properties click on the Clipping Settings button:

In the Clipping Settings, scroll down to the second section and tick the Clip to Item box and select your Ellipse item from the list. (If you have labels shown in your inset map you may also want to check the “force labels inside clipping shape” option to force these labels inside the circle. If you don’t check this option then labels will be allowed to overflow outside of the circle shape.)

Your inset map will now be bound to the ellipse!

Here’s a bit more magic you could add to this map – in the Main Map’s properties, click on Overviews and set create one for the Inset map – it will nicely show the visible circular area and not the rectangle!

Bonus Points: Circular Title Text!

For advanced users, we’ve another fun tip…and when we say fun, we mean ‘let’s play with radians’! Here we’re going to create some title text and a wedged background which curves around the outside of our circular inset. This takes some fiddly playing around, but the end result can be visually striking! Here we’re going to push the QGIS print layout “HTML” item to create some advanced graphics, so some HTML and CSS coding experience is advantageous. (An alternative approach would be to use a vector illustration application like Inkscape, and add your title and circular background as an SVG item in the print layout).

We’ll start by creating some curved circular text:

First, add a “HTML frame” to your print layout:

HTML frames allow placement of dynamic content in your layouts, which can use HTML, CSS and JavaScript to create graphical components.

In the HTML item’s “source” box, add the following code:

<svg height="300" width="350">
            <clipPath id="circleView">
                <circle id="curve" cx="183" cy="156" r="25" fill="transparent" />
        <path id="forText" d="M 28,150, C 25,50, 180,-32,290,130" stroke="" fill="none"/>
            <text x="0" y="35" width="100">
                <textpath xlink:href="#forText">
                    <tspan font-weight="bold" fill="black">Place text here</tspan>
        dominant-baseline: hanging;
        font: 20px Arial;

Now, let’s add in a background to bring more focus onto the title!

To add in the background, create another HTML item. We’ll again create the arc shape using an SVG element, so add the following code into the item’s source box:

<svg width="750" height="750" xmlns="">
  <path d="M 90 70
           A 56 56, 0, 0, 0, 133 140
           L 150 90 Z" fill="#414042" transform=" scale(2.1) rotate(68 150 150) " />/>

(You can read more about SVG  curves and arcs paths over at MDN)

So there we go! These two techniques can help push your QGIS map creations further and make it easier to create beautiful cartography directly in QGIS itself. If you found these tips useful, keep an eye on this blog as we post more tips and tricks over the month of November. And don’t forget to follow the 30 day Map Challenge for a smorgasbord of absolutely stunning maps.

Best of Swiss Enterprise App Award for QField

What a night it was. The “Best of Swiss Apps Awards” took place in Zurich yesterday, November 2, 2022. We were also nominated with QField. And in the enterprise category, the app was so convincing, that it was awarded the highest possible price. So it brought the award “Best of Swiss Enterprise App” home to Graubünden. And as cherry on the cake: QField was also nominated as finalist in the UX/UI category!

We are extremely proud and happy about the received award. And even more when we look at the contendants that won in the other categories. We’re talking companies like SBB, Swiss Life, Switzerland Tourism and, yes, Rivella 🙂.

You can check out all results at

If you are interested in more details, we released a press release in German and in English.

QField is an open source mobile app. The app is designed to use and edit geographically referenced data. In urban environments with 5G connectivity, but also with offline data. The mobile GIS app combines minimal design for simplicity with sophisticated technology for a versatile range of uses to bring data conveniently from the field to the offices. The app was started in 2011 and received a major rebuild in 2022.

QField is mainly funded by customer feature requests, support contracts and sponsoring and is continuously improved an released for Android, iOS, Windows, MacOS and Linux.

It offers a seamless QGIS integration and is GPS-centric, with offline functionality, synchronisation options and desktop configuration. QField is designed for fieldwork: simple, but uncompromising. The app is used internationally and is the first choice for mobile GIS projects. In the city, in the countryside and in the forest.

Soon, QFieldCloud will also be launched. QFieldCloud is a cloud service integrated into QField that enables the remote provision and synchronisation of geodata and projects.

And here some moments of the award night. It was a blast!

2.4.5 - Ecstatic Elk


🐛 Bug Fixes

  • Fix startup crash on iOS 16.1
  • Fix QField-specific variables failure when features have default values set to apply on update

Waste Sampling in the Digital Era - Case of the Czech Republic

Mergin Maps and QGIS used for municipal waste composition survey in the Czech Republic.

Global Environmental Threat of Municipal Waste

The dumping of municipal waste is a global threat to our environment and all life forms.

Currently, there is a distinct trend of less landfilling, as countries move steadily towards alternative ways of recycling and incineration, where material use is not possible.

Dr Martin Pavlas, Associate Professor at the Institute of Process Engineering in the Faculty of Mechanical Engineering at Brno University of Technology in the Czech Republic, is doing important research as part of an EU project regarding municipal waste sampling.

Photo of bins, M. Pavlas

Bins to be sampled (Photo: M. Pavlas)

With the aid of Mergin Maps and QGIS, he is carrying out an extensive municipal waste composition survey in the Czech Republic. Together with Peter Petrik of Lutra Consulting, a unique GIS-based tool was developed for the waste sampling. This includes a prototype mobile application based on Mergin Maps for waste sampling in the field.

Read the full article on

QGIS 3.28 Firenze is released!

We are pleased to announce the release of QGIS 3.28 ‘Firenze’!

Installers for all supported operating systems are already out. QGIS 3.28 comes with tons of new features, as you can see in our visual changelog. QGIS 3.28 Firenze is named after this year’s FOSS4G host city.

We would like to thank the developers, documenters, testers and all the many folks out there who volunteer their time and effort (or fund people to do so). From the QGIS community we hope you enjoy this release! If you wish to donate time, money or otherwise get involved in making QGIS more awesome, please wander along to and lend a hand!

QGIS is supported by donors and sustaining members. A current list of donors who have made financial contributions large and small to the project can be seen on our donors list. If you would like to become a sustaining member, please visit our page for sustaining members for details. Your support helps us fund our six monthly developer meetings, maintain project infrastructure and fund bug fixing efforts.

QGIS is Free software and you are under no obligation to pay anything to use it – in fact we want to encourage people far and wide to use it regardless of what your financial or social status is – we believe empowering people with spatial decision making tools will result in a better society for all of humanity.

Successful crowdfunding campaign - point cloud 3

We are pleased to announce the success of the fund raising campaign, thanks to the great response from the QGIS community. We will publish the full list of the backers soon.

The project will introduce point cloud processing to QGIS and further enhance profile tool and 3D maps. The new processing tools will allow you to create terrain/contours from your point cloud data, handle and manage large datasets and several other processing algorithms. In addition, we intend to allow you to embed profiles in your print layouts, export to other formats (e.g. DXF, CSV) and more improvements to the elevation profile tool. For more details see the crowdfunding page.

The work will start soon in collaboration with the excellent teams from North Road and Hobu. To stay up to date with progress, you can follow this blog or monitor QGIS code repository. If you would like to test the new features and provide us with your feedback, you can install QGIS nightly/master.

2.4.4 - Ecstatic Elk


🐛 Bug Fixes

  • Fix non-atlas printing to PDF (via the main menu)
  • Avoid falling into an endless loop of default value updates

2.4.3 - Ecstatic Elk


Usability improvements

  • Added a documentation button in the 'About QField' popup linking to our growing documentation site.

🐛 Bug Fixes

  • Fixed search bar's go to point feature partially broken when layer CRS doesn't match the project CRS

2.4.2 - Ecstatic Elk

🐛 Bug fixes

  • Further tweaks to sample projects to have them behave better outside of Europe

A New Trick up QField’s Sleeve: Animated Maps

Starting with QField 2.2, users can fully rely on animation capabilities that have made their way into QGIS during its last development cycle. This can be a powerful mean to highlight key elements on a map that require special user attention.

The example below demonstrates a scenario where animated raster markers are used to highlight active fires within the visible map extent. Notice how the subtle fire animation helps draw viewers’ eyes to those important markers.

Animated raster markers is a new symbol layer type in QGIS 3.26 that was developed by Nyall Dawson. Supported image formats include GIF, WEBP, and APNG.

The second example below showcases more advanced animated symbology which relies on expressions to animate several symbol properties such as marker size, border width, and color opacity. While more complex than simply adding a GIF marker, the results achieved with data-defined properties animation can be very appealing and integrate perfectly with any type of project.

You’ll quickly notice how smooth the animation runs. That is thanks to’s own ninjas having spent time improving the map canvas element’s handling of layers constantly refreshing. This includes automatic skipping of frames on older devices so the app remains responsive.

Oh, we couldn’t help ourselves but take the opportunity to demonstrate how nice the QField feature form layout is these days in the video above 😄 To know more about other new features in QField 2.2, go and read the release page.

Happy field mapping to all!

The lovely animal markers used in the zoo example above were made by Serbian artist Arsenije Vujovic.

Writing a feature-based processing algorithm at the example of M-value interpolation

Amongst all the processing algorithms already available in QGIS, sometimes the one thing you need is missing. 

This happened not a long time ago, when we were asked to find a way to continuously visualise traffic on the Swiss motorway network (polylines) using frequently measured traffic volumes from discrete measurement stations (points) alongside the motorways. In order to keep working with the existing polylines, and be able to attribute more than one value of traffic to each feature, we chose to work with the M-values. M-values are a per-vertex attribute like X, Y or Z coordinates. They contain a measure value, which typically represents time or distance. But they can hold any numeric value.

In our example, traffic measurement values are provided on a separate point layer and should be attributed to the M-value of the nearest vertex of the motorway polylines. Of course, the motorway features should be of type LineStringM in order to hold an M-value. We then should interpolate the M-values for each feature over all vertices in order to get continuous values along the line (i.e. a value on every vertex). This last part is not yet existing as a processing algorithm in QGIS.

This article describes how to write a feature-based processing algorithm based on the example of M-value interpolation along LineStrings.

Feature-based processing algorithm

The pyqgis class QgsProcessingFeatureBasedAlgorithm is described as follows: “An abstract QgsProcessingAlgorithm base class for processing algorithms which operates “feature-by-feature”.  

Feature based algorithms are algorithms which operate on individual features in isolation. These are algorithms where one feature is output for each input feature, and the output feature result for each input feature is not dependent on any other features present in the source. […]

Using QgsProcessingFeatureBasedAlgorithm as the base class for feature based algorithms allows shortcutting much of the common algorithm code for handling iterating over sources and pushing features to output sinks. It also allows the algorithm execution to be optimised in future (for instance allowing automatic multi-thread processing of the algorithm, or use of the algorithm in “chains”, avoiding the need for temporary outputs in multi-step models).

In other words, when connecting several processing algorithms one after the other – e.g. with the graphical modeller – these feature-based processing algorithms can easily be used to fill in the missing bits. 

Compared to the standard QgsProcessingAlgorithm the feature-based class implicitly iterates over each feature when executing and avoids writing wordy loops explicitly fetching and applying the algorithm to each feature. 

Just like for the QgsProcessingAlgorithm (a template can be found in the Processing Toolbar > Scripts > Create New Script from Template), there is quite some boilerplate code in the QgsProcessingFeatureBasedAlgorithm. The first part is identical to any QgsProcessingAlgorithm.

After the description of the algorithm (name, group, short help, etc.), the algorithm is initialised with def initAlgorithm, defining input and output. 

In our M-value example:

    def initAlgorithm(self, config=None):
      'Input layer'),
      'Output layer')

While in a regular processing algorithm now follows def processAlgorithm(self, parameters, context, feedback), in a feature-based algorithm we use def processFeature(self, feature, context, feedback). This implies applying the code in this block to each feature of the input layer. 

! Do not use def processAlgorithm in the same script, otherwise your feature-based processing algorithm will not work !

Interpolating M-values

This actual processing part can be copied and added almost 1:1 from any other independent python script, there is little specific syntax to make it a processing algorithm. Only the first line below really.

In our M-value example:

    def processFeature(self, feature, context, feedback):
            geom = feature.geometry()
            line = geom.constGet()
            vertex_iterator = QgsVertexIterator(line)
            vertex_m = []

            # Iterate over all vertices of the feature and extract M-value

            while vertex_iterator.hasNext():
                vertex =

            # Extract length of segments between vertices

            vertices_indices = range(len(vertex_m))
            length_segments = [sqrt(QgsPointXY(line[i]).sqrDist(QgsPointXY(line[j]))) 
                for i,j in itertools.combinations(vertices_indices, 2) 
                if (j - i) == 1]

            # Get all non-zero M-value indices as an array, where interpolations 
              have to start

            vertex_si = np.nonzero(vertex_m)[0]
            m_interpolated = np.copy(vertex_m)

            # Interpolate between all non-zero M-values - take segment lengths between 
              vertices into account

            for i in range(len(vertex_si)-1):
                first_nonzero = vertex_m[vertex_si[i]]
                next_nonzero = vertex_m[vertex_si[i+1]]
                accum_dist = itertools.accumulate(length_segments[vertex_si[i]
                sum_seg = sum(length_segments[vertex_si[i]:vertex_si[i+1]])
                interp_m = [round(((dist/sum_seg)*(next_nonzero-first_nonzero)) + 
                            first_nonzero,0) for dist in accum_dist]
                m_interpolated[vertex_si[i]:vertex_si[i+1]] = interp_m

            # Copy feature geometry and set interpolated M-values, 
              attribute new geometry to feature

            geom_new = QgsLineString(geom.constGet())
            for j in range(len(m_interpolated)):
            attrs = feature.attributes()
            feat_new = QgsFeature()

        except Exception:
            s = traceback.format_exc()
            self.num_bad += 1
            return []
        return [feat_new]

In our example, we get the feature’s geometry, iterate over all its vertices (using the QgsVertexIterator) and extract the M-values as an array. This allows us to assign interpolated values where we don’t have M-values available. Such missing values are initially set to a value of 0 (zero).

We also extract the length of the segments between the vertices. By gathering the indices of the non-zero M-values of the array, we can then interpolate between all non-zero M-values, considering the length that separates the zero-value vertex from the first and the next non-zero vertex.

For the iterations over the vertices to extract the length of the segments between them as well as for the actual interpolation between all non-zero M-value vertices we use the library itertools. This library provides different iterator building blocks that come in quite handy for our use case. 

Finally, we create a new geometry by copying the one which is being processed and setting the M-values to the newly interpolated ones.

And that’s all there is really!

Alternatively, the interpolation can be made using the interp function of the numpy library. Some parts where our manual method gave no values, interp.numpy seemed more capable of interpolating. It remains to be judged which version has the more realistic results.

Styling the result via M-values

The last step is styling our output layer in QGIS, based on the M-values (our traffic M-values are categorised from 1 [a lot of traffic -> dark red] to 6 [no traffic -> light green]). This can be achieved by using a Single Symbol symbology with a Marker Line type “on every vertex”. As a marker type, we use a simple round point. Stroke style is “no pen” and Stroke fill is based on an expression:


'm_value', m(point_n($geometry, @geometry_point_num)),

	CASE WHEN @m_value = 6
		THEN color_rgb(140, 255, 159)

		WHEN @m_value = 5
			THEN color_rgb(244, 252, 0)

		WHEN @m_value = 4
			THEN color_rgb(252, 176, 0)

		WHEN @m_value = 3
			THEN color_rgb(252, 134, 0)

		WHEN @m_value = 2
			THEN color_rgb(252, 29, 0)

		WHEN @m_value = 1
			THEN color_rgb(140, 255, 159)



And voilà! Wherever we have enough measurements on one line feature, we get our motorway network continuously coloured according to the measured traffic volume.

One disclaimer at the end: We get this seemingly continuous styling only because of the combination of our “complex” polylines (containing many vertices) and the zoomed-out view of the motorway network. Because really, we’re styling many points and not directly the line itself. But in our case, this is working very well.

If you’d like to make your custom processing algorithm available through the processing toolbox in your QGIS, just put your script in the folder containing the files related to your user profile:

profiles > default > processing > scripts 

You can directly access this folder by clicking on Settings > User Profiles > Open Active Profile Folder in the QGIS menu.

That way, it’s also available for integration in the graphical modeller.

Extract of the Graphical Modeler sequence. “Interpolate M-values neg” refers to the custom feature-based processing algorithm described above.

You can download the above-mentioned processing scripts (with numpy and without numpy) here.

Happy processing!

  • <<
  • Page 2 of 128 ( 2553 posts )
  • >>

Back to Top

Sustaining Members