Skip to content

opengeos/qgis-leafmap-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Leafmap QGIS Plugin

A powerful QGIS plugin for interactive layer visualization and comparison, inspired by the leafmap Python package.

Features

  • Layer Transparency Control: Interactive slider to adjust layer transparency in real-time for all loaded layers
  • Layer Swipe Tool: Compare two layers side-by-side with a draggable divider (similar to ipyleaflet split control)
  • Dockable Panels: All tools are available as dockable panels that can be positioned anywhere in the QGIS interface
  • Plugin Update Checker: Check for updates from GitHub and install them automatically
  • Settings Panel: Configure plugin options with persistent storage

Screenshots

Layer Transparency Panel

Control the transparency of all layers with individual sliders. Filter by layer type (raster/vector) and visibility.

Layer Swipe Tool

Compare two layers by swiping between them. Select left and right layers, choose vertical or horizontal orientation, and drag the divider on the map.

Video Tutorial

πŸ‘‰ Compare Layers Visually in QGIS β€” New Leafmap Plugin Demo!

Leafmap QGIS Plugin

Requirements

  • QGIS 3.28 or later
  • Python 3.10+

Installation

Option A: QGIS Plugin Manager (Recommended)

  1. Open QGIS
  2. Go to Plugins β†’ Manage and Install Plugins...
  3. Go to the Settings tab
  4. Click Add... under "Plugin Repositories"
  5. Give a name for the repository, e.g., "OpenGeos"
  6. Enter the URL of the repository: https://qgis.gishub.org/plugins.xml
  7. Click OK
  8. Go to the All tab
  9. Search for "Leafmap"
  10. Select the plugin and click Install Plugin

Option B: Install Script

Using Python:

# Clone the repository
git clone https://github.com/opengeos/qgis-leafmap-plugin.git
cd qgis-leafmap-plugin

# Install
python install.py

# Or remove
python install.py --remove

Using Bash:

# Make executable (first time only)
chmod +x install.sh

# Install
./install.sh

# Or remove
./install.sh --remove

Option C: Manual Installation

Copy the qgis_leafmap folder to your QGIS plugins directory:

  • Linux: ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/
  • macOS: ~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/
  • Windows: %APPDATA%\QGIS\QGIS3\profiles\default\python\plugins\

Usage

Layer Transparency

  1. Click the Layer Transparency button in the toolbar or go to Leafmap β†’ Layer Transparency
  2. A dockable panel will appear with sliders for each layer
  3. Drag the slider to adjust transparency (0% = opaque, 100% = transparent)
  4. Use the filter options to show only raster or vector layers
  5. Use "Reset All" to restore all layers to 0% transparency

Layer Swipe Tool

  1. Click the Layer Swipe button in the toolbar or go to Leafmap β†’ Layer Swipe
  2. Select the Left Layer (shown on left side of divider)
  3. Select the Right Layer (shown on right side of divider)
  4. Choose Vertical or Horizontal orientation
  5. Click Activate Swipe
  6. Drag the divider on the map to compare layers
  7. Use the slider or quick buttons to adjust the divider position
  8. Click Deactivate Swipe when done

Settings

  1. Go to Leafmap β†’ Settings
  2. Adjust general, transparency, and swipe tool options
  3. Click Save Settings to persist changes

Check for Updates

  1. Go to Leafmap β†’ Check for Updates...
  2. Click Check for Updates to see if a new version is available
  3. If an update is available, click Download and Install Update
  4. Restart QGIS to apply the update

Project Structure

qgis-leafmap-plugin/
β”œβ”€β”€ qgis_leafmap/
β”‚   β”œβ”€β”€ __init__.py              # Plugin entry point
β”‚   β”œβ”€β”€ qgis_leafmap.py          # Main plugin class
β”‚   β”œβ”€β”€ metadata.txt             # Plugin metadata for QGIS
β”‚   β”œβ”€β”€ LICENSE                  # Plugin license
β”‚   β”œβ”€β”€ dialogs/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ transparency_dock.py # Layer transparency panel
β”‚   β”‚   β”œβ”€β”€ swipe_dock.py        # Layer swipe/comparison tool
β”‚   β”‚   β”œβ”€β”€ settings_dock.py     # Settings panel
β”‚   β”‚   └── update_checker.py    # Update checker dialog
β”‚   └── icons/
β”‚       β”œβ”€β”€ icon.svg             # Main plugin icon
β”‚       β”œβ”€β”€ transparency.svg     # Transparency tool icon
β”‚       β”œβ”€β”€ swipe.svg            # Swipe tool icon
β”‚       β”œβ”€β”€ settings.svg         # Settings icon
β”‚       └── about.svg            # About icon
β”œβ”€β”€ package_plugin.py            # Python packaging script
β”œβ”€β”€ package_plugin.sh            # Bash packaging script
β”œβ”€β”€ install.py                   # Python installation script
β”œβ”€β”€ install.sh                   # Bash installation script
β”œβ”€β”€ README.md                    # This file
└── LICENSE                      # Repository license

Development

Testing with Conda Environment

For testing with the geo conda environment:

# Activate the geo environment
conda activate geo

# Install the plugin
python install.py

# Start QGIS from the terminal to see any error messages
qgis

Adding New Features

  1. Create new dock widgets in the dialogs/ folder
  2. Add corresponding toggle methods in qgis_leafmap.py
  3. Create icons in the icons/ folder
  4. Update dialogs/__init__.py with new imports

Packaging for QGIS Plugin Repository

Using Python Script

# Default packaging
python package_plugin.py

# Custom output path
python package_plugin.py --output /path/to/qgis_leafmap.zip

# Without version in filename
python package_plugin.py --no-version

Using Bash Script

# Make executable (first time only)
chmod +x package_plugin.sh

# Default packaging
./package_plugin.sh

# Custom output directory
./package_plugin.sh --output /path/to/output

Uploading to QGIS Plugin Repository

  1. Create an account at plugins.qgis.org
  2. Go to "My plugins" and click "Add a new plugin"
  3. Upload the generated zip file
  4. Fill in the required information
  5. Submit for review

Related Projects

  • leafmap - A Python package for interactive mapping and geospatial analysis
  • ipyleaflet - A Jupyter widget for Leaflet.js interactive maps
  • geemap - A Python package for interactive mapping with Google Earth Engine

License

This plugin is released under the MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Links