Skip to content

lcsmarcone/modelai

Repository files navigation

QGIS AI Model Builder

CI License: GPL-2.0

Natural language interface to build geoprocessing workflows in QGIS

QGIS AI Model Builder is a QGIS plugin that converts natural language instructions into complete geoprocessing workflows. Describe your spatial task in plain language, and the plugin generates a Processing pipeline that you can visualize, edit, and execute directly in QGIS.

Features

  • Natural Language Input: Describe workflows in plain language (e.g., "create a 1000m buffer around parcels and calculate area in hectares")
  • Automatic Pipeline Generation: Converts instructions into structured QGIS Processing workflows
  • Workflow Visualization: View pipeline steps and parameters before execution
  • Model Designer Integration: Export and open workflows in QGIS Model Designer for manual editing
  • Layer Detection: Automatically suggests the best matching layer based on name, geometry type, and active layer
  • Background Execution: Runs workflows using QgsTask to prevent UI freezing

Supported Algorithms (MVP)

The MVP version supports the following QGIS Processing algorithms:

  • Buffer (native:buffer)
  • Reproject (native:reprojectlayer)
  • Field Calculator (native:fieldcalculator)
  • Fix Geometries (native:fixgeometries)
  • Dissolve (native:dissolve)
  • Clip (native:clip)
  • Intersection (native:intersection)

Installation

From QGIS Plugin Repository (Coming Soon)

  1. Open QGIS
  2. Go to PluginsManage and Install Plugins
  3. Search for "QGIS AI Model Builder"
  4. Click Install Plugin

Manual Installation

  1. Download or clone this repository
  2. Copy the plugin folder to your QGIS plugins directory:
    • Windows: C:\Users\<username>\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\
    • Linux: ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/
    • macOS: ~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/
  3. Restart QGIS
  4. Enable the plugin in PluginsManage and Install PluginsInstalled

Requirements

  • QGIS 3.28 or higher
  • Python 3.9 or higher

Usage

  1. Open the Plugin: Go to PluginsAI Model Builder (or use the toolbar button)
  2. Describe Your Workflow: Type your spatial task in natural language
    • Example: "buffer the parcels by 1000 meters, dissolve by municipality and calculate total area"
  3. Generate Workflow: Click Generate Workflow to create the pipeline
  4. Preview Steps: Review the generated workflow steps and parameters
  5. Execute or Edit:
    • Click Run Workflow to execute directly
    • Click Open in Model Designer to edit the workflow manually

Example

Input: "Create a 1000 meter buffer around parcels and calculate area in hectares"

Generated Pipeline:
1. Reproject layer (if CRS is geographic)
2. Buffer (distance: 1000m)
3. Add field (area_ha)
4. Calculate area (expression: $area / 10000)

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/lcsmarcone/modelai.git
cd modelai

# Install Poetry (if not already installed)
# See: https://python-poetry.org/docs/#installation

# Install dependencies
poetry install

Running Tests

# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov=.

# Run specific test file
poetry run pytest tests/test_pipeline_generation.py

Code Quality

# Lint code
poetry run ruff check .

# Format code
poetry run ruff format .

Project Structure

modelai/
├── core/              # Core functionality
│   ├── planner.py           # Pipeline generation
│   ├── pipeline_executor.py # Workflow execution
│   ├── layer_resolver.py    # Layer detection
│   └── pipeline_schema.py   # Pipeline validation
├── ui/                # User interface
│   ├── main_dialog.py       # Main plugin dialog
│   └── pipeline_view.py     # Pipeline visualization
├── models/            # Model export
│   └── model_exporter.py    # Model Designer export
├── tests/             # Test suite
└── docs/              # Documentation

Roadmap

MVP (Current)

  • ✅ Basic pipeline generation from natural language
  • ✅ Workflow visualization
  • ✅ Background execution
  • ✅ Layer detection
  • ✅ Model Designer integration

Future Versions

  • LLM integration (OpenAI, Claude, local models)
  • Advanced workflow graph engine
  • Iterative workflow editing
  • Field resolver
  • Automatic CRS handling
  • Privacy modes (metadata-only, sample data)
  • Multiple LLM provider support

See FULL_VISION.md for the complete roadmap.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the GNU General Public License v2.0 (GPL-2.0) - see the LICENSE file for details.

Acknowledgments

  • Built for the QGIS Processing Framework
  • Inspired by the need for more accessible geoprocessing workflows

Support

Status

🚧 This plugin is currently in MVP development phase

The plugin is experimental and under active development. Features may change between versions.

About

Natural language interface to build geoprocessing workflows in QGIS

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages