Compare Geospatial Layers in QGIS with the LeafMap Plugin
If you have used leafmap or ipyleaflet, you are probably familiar with interactive tools like layer transparency sliders and split-map controls for comparing datasets side by side. I have not found a good QGIS plugin that provides similar functionality, so I built one. The LeafMap QGIS plugin brings two essential tools to QGIS: dynamic layer transparency and a layer swipe tool for comparing any two layers.
In this short tutorial, I walk through installing the plugin and using both features with real-world data, including a before-and-after comparison of the 2023 Libya flooding.
Video tutorial: LeafMap QGIS Plugin for Layer Comparison
What You Will Need¶
QGIS desktop (any standard installation works; Pixi is not required for this plugin)
Install the Plugin¶
The plugin is available in the official QGIS Plugin Repository:
Go to Plugins > Manage and Install Plugins.
Search for leafmap.
Click Install Plugin.
After installation, three buttons appear in the toolbar and a LeafMap menu appears in the menu bar. The plugin includes a built-in update checker: go to LeafMap > Check for Updates to get the latest version from GitHub.
Layer Transparency¶
The layer transparency tool provides a real-time slider for adjusting the opacity of any layer without opening the layer properties dialog.
Click the Layer Transparency button in the toolbar.
A panel opens on the right showing all loaded layers with individual transparency sliders.
Drag a slider to the right to increase transparency (0% is fully opaque, 100% is fully transparent).
This is much faster than the built-in QGIS workflow of double-clicking a layer, navigating to the transparency tab, entering a value, and clicking OK. The slider updates the display in real time as you drag.
You can toggle between showing all layers or only visible layers using the checkbox at the top of the panel.
Layer Swipe¶
The layer swipe tool lets you compare two layers side by side with a draggable divider, similar to the split-map controls in leafmap and ipyleaflet.
Set up the comparison¶
Click the Layer Swipe button in the toolbar.
Select the left layer from the dropdown.
Select the right layer from the dropdown.
Choose the swipe direction: vertical (left/right divider) or horizontal (top/bottom divider).
Click Activate Swipe.
Use the swipe¶
Drag the divider across the map to reveal more or less of each layer. You can also set the position precisely using the percentage buttons (25%, 50%, 75%).
When you are done, click Deactivate Swipe to return to normal map view.
Example: Libya Flooding Change Detection¶
The swipe tool is particularly useful for comparing pre- and post-event satellite imagery. Using Maxar Open Data imagery from the 2023 Libya flooding:
Load two GeoTIFF files: one from July 1, 2023 (pre-event) and one from September 13, 2023 (post-event).
Open the swipe tool.
Set the July image as the left layer and the September image as the right layer.
Activate the swipe and drag the divider to compare.
The comparison clearly reveals the destruction: bridges collapsed, roads washed away, and the landscape dramatically altered by the flood. This kind of visual comparison is essential for damage assessment and change detection workflows.
Works with Any Layer Type¶
The swipe tool works with any combination of QGIS layers:
Raster vs. raster (satellite imagery comparison)
Basemap vs. basemap (Google Satellite vs. OpenStreetMap)
Vector vs. raster (boundaries overlaid on imagery)
Any two layers you need to compare
Resources¶
GitHub Repository: github
.com /opengeos /qgis -leafmap -plugin LeafMap Documentation: leafmap.org
More features will be added to the plugin in future releases. Follow the GitHub repository for updates, and feel free to open an issue if you have feature requests or run into any problems.