How Do You Match the Same Road Across Two Datasets?
A QGIS plugin for matching road features and transferring attributes.
Have you ever had two road datasets covering the same area, but with different attributes or levels of detail? You may have the information you need in one dataset, but the road geometry you actually want to use is in another.
Over the past few weeks, I've been building Conflate Roads, a QGIS plugin designed to match corresponding roads between two line datasets and transfer selected attributes from one to the other.
In this post, I'll walk through a simple example using the sample data included in the official plugin repository. We'll transfer attributes from osm_roads to ordnance_roads.
How to Use the Plugin
Before running the plugin, make sure your QGIS environment is configured as described in the plugin documentation. For this walkthrough, I'll assume everything is ready to go.
First, install Conflate Roads from the QGIS Plugin Manager. Once installed, you can access it from the Vector menu.
The plugin asks you to provide a few things:
Source layer: the layer containing the attributes you want to transfer (osm_roads).
Destination layer: the layer whose roads will be matched and updated (ordnance_roads). (Note: Both must be vector layers using the same projected, metric CRS.)
Attributes: the specific fields you want to transfer.
Road pattern: the type of road network being processed.
Search buffer: how far the plugin should look (in meters) when searching for potential matches. The default is 50 m.
Output file: where you want to save the final enriched dataset.
If your two datasets aren't closely aligned, you may need to increase the search buffer. Just keep in mind that a larger search distance also means more potential matches for the plugin to evaluate, which can increase processing time.
Run the plugin and let it do the matching.
What happens next?
When the process finishes, a small dialog displays the matching statistics, including the number of roads matched and those that could not be matched.
Load the output layer into QGIS and inspect a few of the features. The destination roads now contain attributes transferred from their corresponding roads in the source dataset.
A few things I learned along the way
Road datasets are rarely as neat as we would like them to be. A few things can make a surprisingly big difference to the matching results.
Make the datasets line up.
If corresponding roads are significantly displaced, some preprocessing can help. An optional affine transformation can improve the spatial overlap before running the matching process.
Watch out for long road segments.
One dataset might represent a road as a single long feature, while another splits the same road into several shorter segments.
This can cause problems because the plugin evaluates the Hausdorff distance between individual candidate features. A long segment may therefore fail the distance threshold even when it's clearly the same road. Splitting long segments at existing vertices can help in these situations.
Multipart features deserve some attention.
The plugin factors road sinuosity during the matching process. This assumes that multipart features represent a continuous road with parts connected in sequence. Disconnected parts can produce misleading sinuosity values.
Of course, not every road will find a match. If no suitable candidate falls within the specified distance threshold, the feature is left unmatched.
Give it a try
Conflate Roads is still a work in progress, and I'm particularly interested in seeing how it performs on different road datasets and patterns. If you try it, I'd love to hear where you think it could be improved. You can download the plugin and drop your feedback, issues, or pull requests via the GitHub Repository link.
Thank you for reading this post.