Skip to content

Latest commit

ย 

History

64 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GeoPilot - AI Geospatial Assistant for QGIS

QGIS Python License GitHub Release Downloads


GeoPilot is an AI-powered geospatial analysis assistant plugin for QGIS that lets you control QGIS through natural language. Tell GeoPilot what you want to do in plain Chinese or English โ€” it will automatically generate and execute QGIS Python code to process data, run analyses, and create publication-ready figures.

๐Ÿ”ฅ Key Innovation: Unlike other AI plugins that only chat, GeoPilot actually executes code in QGIS. Your maps, buffers, NDVI, and classifications happen in real-time โ€” no copy-pasting required.


โœจ Features

๐ŸŽฏ Core Capabilities

  • Natural Language โ†’ QGIS Operations: Describe tasks in plain language, GeoPilot generates Python code for you
  • Reviewed Code Execution: AI-generated Python is shown in chat; by default you confirm before it runs (auto-run is opt-in)
  • 18 AI Providers: OpenAI, DeepSeek, Moonshot, Qwen, Zhipu, Yi, Mistral, Cohere, Perplexity, xAI Grok, Together AI, Fireworks AI, Groq, Anthropic Claude, Google Gemini, Ollama (Local), Baidu ERNIE, iFlytek Spark
  • Smart Context Awareness: Auto-detects current layers, CRS, fields, and available algorithms to inform the AI
  • Safe-by-default networking: SSL certificate verification, HTTP error handling, and a blocklist of dangerous builtins (os.system, subprocess, shutil.rmtree, eval)

๐Ÿ—บ๏ธ Geospatial Analysis

Category Capabilities
Vector Analysis Buffer, Clip, Union, Intersect, Dissolve, Spatial Join, Merge, Reproject, Field Calculator
Raster Analysis Slope, Aspect, Hillshade, Contour, Raster Calculator, Reclassify, Polygonize
Remote Sensing 28+ spectral indices (NDVI, EVI, SAVI, NDWI, MNDWI, NBR, etc.), Land Cover Classification, Change Detection
Spatial Statistics Hotspot Analysis (Getis-Ord Gi*), Moran's I, LISA, Kernel Density, Voronoi
Network Analysis Shortest Path, Service Area
SCI Figures Study Area Map, Land Cover, Accuracy Assessment, Change Detection, Spatial Pattern, Graphical Abstract

๐ŸŒ Multi-Language Support

  • Chinese & English interface and AI responses
  • All Chinese AI providers natively supported (DeepSeek, Moonshot, Qwen, Zhipu, Baidu, Spark, Yi)

๐Ÿ“ฆ Installation

Prerequisites

  • QGIS 3.30+ (tested on 3.44.2)
  • Internet connection (for cloud AI providers)
  • API key for your chosen AI provider (except Ollama which runs locally)

Quick Install (From Release ZIP)

1. Download GeoPilot-v1.1.0.zip from GitHub Releases
2. Open QGIS โ†’ Plugins โ†’ Manage and Install Plugins
3. Click "Install from ZIP" โ†’ Select the downloaded file
4. Restart QGIS
5. Enable GeoPilot in Plugins โ†’ Installed tab

Manual Install

# Clone
git clone https://github.com/xingguangYan/GeoPilot.git

# Copy to QGIS plugins directory (Windows)
xcopy /E /I GeoPilot "%APPDATA%/QGIS/QGIS3/profiles/default/python/plugins/GeoPilot/"

๐Ÿš€ Quick Start

1. Launch GeoPilot

Click the GeoPilot icon ๐ŸŒ in the QGIS toolbar, or go to Plugins โ†’ GeoPilot โ†’ GeoPilot Chat.

2. Configure Your AI Provider

Click Provider Settings (โš™) to expand settings:

Provider: DeepSeek       # Select your preferred AI
Model: deepseek-chat     # Select model version
API Key: sk-...          # Enter your API key
Base URL: (leave default) # Most providers have pre-configured endpoints

3. Start Working!

Just type what you want in natural language. GeoPilot will:

  1. Understand your request and gather the current QGIS project context
  2. Generate QGIS Python code and show it in the chat
  3. Ask you to confirm before running the code (uncheck "Auto-execute" in Provider Settings to skip)
  4. Execute the confirmed code and show results (layers, output, or errors) in the chat

๐Ÿ’ฌ Example Prompts

Category Example
Buffer ๅฏน้“่ทฏๅ›พๅฑ‚ๅš100็ฑณ็ผ“ๅ†ฒๅŒบ / "Buffer the roads layer by 100 meters"
Clip ็”จ็ ”็ฉถๅŒบ่พน็•Œ่ฃๅ‰ชๆ‰€ๆœ‰ๅ›พๅฑ‚ / "Clip all layers by the study area boundary"
NDVI ่ฎก็ฎ—ๅฝ“ๅ‰ๅฝฑๅƒ็š„NDVIๅนถๆ˜พ็คบ / "Calculate NDVI from the current image"
Classification ็”จ้šๆœบๆฃฎๆž—ๅš5็ฑปๅœŸๅœฐๅˆฉ็”จๅˆ†็ฑป / "Run Random Forest classification with 5 classes"
Change Detection ๆฃ€ๆต‹2015ๅˆฐ2020็š„ๅŸŽๅธ‚ๆ‰ฉๅผ  / "Detect urban expansion from 2015 to 2020"
Hotspot ๅˆ†ๆž็Šฏ็ฝชๆ•ฐๆฎ็š„็ƒญ็‚นๅŒบๅŸŸ / "Find crime hotspots in the point layer"
Export Figure ็”Ÿๆˆ็ ”็ฉถๅŒบ็คบๆ„ๅ›พ๏ผŒๅŒ…ๅซๆฏ”ไพ‹ๅฐบๆŒ‡ๅŒ—้’ˆ / "Create a study area map with scale bar and north arrow"
Batch ๅฏนๆฏไธช็Ÿข้‡ๅ›พๅฑ‚ๆŒ‰ๅญ—ๆฎต่žๅˆ / "Dissolve each vector layer by its name field"

๐Ÿ”ง AI Provider Configuration

Getting API Keys

Provider Get API Key Best For
OpenAI platform.openai.com General purpose, best quality
DeepSeek platform.deepseek.com Cost-effective, Chinese support
Moonshot/Kimi platform.moonshot.cn Chinese, long context
Qwen (Tongyi) bailian.console.aliyun.com Chinese, Alibaba ecosystem
Zhipu GLM open.bigmodel.cn Chinese, code generation
Yi (01.AI) platform.01.ai Chinese, fast responses
Anthropic Claude console.anthropic.com Long context, analysis
Google Gemini aistudio.google.com Free tier available
Ollama (Local) No key needed (local) Offline use, free

Supported Models

Provider Models
OpenAI gpt-4o, gpt-4o-mini, gpt-4-turbo, o1, o1-mini, o3-mini, gpt-4.1
DeepSeek deepseek-chat, deepseek-reasoner, deepseek-v3, deepseek-r1, deepseek-v4-pro, deepseek-v4-flash
Moonshot moonshot-v1-8k, moonshot-v1-32k, moonshot-v1-128k, moonshot-v1-auto
Qwen qwen-max, qwen-plus, qwen-turbo, qwen-long, qwen2.5-72b-instruct
Zhipu glm-4-plus, glm-4, glm-4-flash, glm-4-air, glm-4v-plus
Yi yi-lightning, yi-medium, yi-large, yi-vision, yi-large-turbo
Mistral mistral-large-latest, mistral-small-latest, codestral-latest
Anthropic claude-sonnet-4-20250514, claude-3-5-sonnet-20241022, claude-3-5-haiku
Google gemini-2.5-pro-exp-03-25, gemini-2.0-flash, gemini-1.5-pro
Ollama llama3.3, llama3.1, mistral, qwen2.5, deepseek-r1, phi4
Baidu ernie-4.0-8k, ernie-3.5-8k, ernie-speed, ernie-lite
Spark 4.0Ultra, 4.0, 3.5, 3.0
xAI Grok grok-beta, grok-2, grok-2-vision, grok-3
Perplexity sonar-pro, sonar, sonar-reasoning
Groq llama-3.3-70b-versatile, mixtral-8x7b, gemma2-9b-it
Together AI meta-llama-3.3-70b, deepseek-ai/DeepSeek-R1
Fireworks AI llama-v3p3-70b, qwen2p5-72b, deepseek-r1
Cohere command-r-plus, command-r7-12-2024, command-a-03-2025

๐ŸŽจ GUI Overview

GeoPilot features a modern dark-theme chat interface:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  GeoPilot - AI Geospatial Assistant  [? Help] โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โš™ Provider Settings (collapsible)          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚ Provider: [DeepSeek โ–ผ] Model: [.. โ–ผ]โ”‚    โ”‚
โ”‚  โ”‚ API Key: [โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข]        โ”‚    โ”‚
โ”‚  โ”‚ Base URL: [______________]          โ”‚    โ”‚
โ”‚  โ”‚ System Prompt: [______________]     โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ๐Ÿ’ฌ Welcome to GeoPilot!                    โ”‚
โ”‚  ๐ŸŒ Your AI Geospatial Assistant             โ”‚
โ”‚                                             โ”‚
โ”‚  1. โš™ Click Provider Settings to configure  โ”‚
โ”‚  2. ๐Ÿ“ Type your task in natural language    โ”‚
โ”‚  3. ๐Ÿค– GeoPilot executes code automatically  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  [Describe your task here...        ] [โ–ถ Send] โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Help Panel

Click ? Help to reveal quick-prompt buttons for common tasks:

  • ๐ŸŒŽ Study Area Analysis
  • ๐ŸŒฟ Vegetation Analysis (NDVI)
  • ๐Ÿ™๏ธ Land Cover Classification
  • ๐Ÿ“Š Change Detection
  • ๐ŸŒ Spatial Pattern Analysis
  • ๐Ÿ“„ Export Research Report

๐Ÿ—๏ธ Project Architecture

GeoPilot/
โ”œโ”€โ”€ __init__.py              # Plugin entry point (classFactory)
โ”œโ”€โ”€ geopilot.py               # Main plugin class (menu, toolbar)
โ”œโ”€โ”€ geopilot_dialog.py        # Chat dialog + auto-execution engine
โ”œโ”€โ”€ metadata.txt              # QGIS plugin metadata
โ”œโ”€โ”€ README.md                 # This file
โ”œโ”€โ”€ LICENSE                   # MIT License
โ”œโ”€โ”€ Makefile                  # Build automation
โ”‚
โ”œโ”€โ”€ providers/                # ๐Ÿง  AI Provider System (18 providers)
โ”‚   โ”œโ”€โ”€ __init__.py           # Provider registry (all 18 registered)
โ”‚   โ”œโ”€โ”€ base.py               # BaseProvider, register_provider()
โ”‚   โ”œโ”€โ”€ openai_compat.py      # OpenAI + 13 compatible providers
โ”‚   โ”œโ”€โ”€ anthropic_provider.py # Anthropic Claude
โ”‚   โ”œโ”€โ”€ google_provider.py    # Google Gemini
โ”‚   โ”œโ”€โ”€ baidu_provider.py     # Baidu ERNIE (OAuth)
โ”‚   โ”œโ”€โ”€ spark_provider.py     # iFlytek Spark
โ”‚   โ””โ”€โ”€ ollama_provider.py    # Local Ollama
โ”‚
โ”œโ”€โ”€ scripts/                  # โš™๏ธ GeoAI Analysis Engine
โ”‚   โ”œโ”€โ”€ geoai_data_manager.py    # Data I/O (Shapefile, GeoJSON, GPKG, etc.)
โ”‚   โ”œโ”€โ”€ geoai_vector_analysis.py # Buffer, Clip, Union, Spatial Join
โ”‚   โ”œโ”€โ”€ geoai_raster_analysis.py # GDAL, SAGA, GRASS raster ops
โ”‚   โ”œโ”€โ”€ geoai_remote_sensing.py  # 28 spectral indices, 8 classifiers
โ”‚   โ”œโ”€โ”€ geoai_sci_figure.py      # Figure 1-8, Graphical Abstract, Poster
โ”‚   โ”œโ”€โ”€ geoai_paper_agent.py     # Journal recommendation, Cover Letter
โ”‚   โ”œโ”€โ”€ geoai_pipeline.py        # 6 pre-built analysis workflows
โ”‚   โ”œโ”€โ”€ geoai_report.py          # Research report generator
โ”‚   โ”œโ”€โ”€ geoai_qgis_bootstrap.py  # QGIS environment initialization
โ”‚   โ”œโ”€โ”€ geoai_gee_bridge.py      # Google Earth Engine integration
โ”‚   โ”œโ”€โ”€ geoai_env_setup.py       # Environment detection
โ”‚   โ””โ”€โ”€ geoai.py                 # CLI interface
โ”‚
โ””โ”€โ”€ icons/                    # ๐ŸŽจ Plugin icons
    โ”œโ”€โ”€ icon.png
    โ””โ”€โ”€ icon.svg

๐Ÿง  How Code Execution Works

The core innovation of GeoPilot is the review-then-execute pipeline:

flowchart LR
    A[User: "Buffer by 100m"] --> B[AI generates Python code]
    B --> C[Code extracted from response]
    C --> D{Auto-execute enabled?}
    D -- No (default) --> E[User confirms in dialog]
    D -- Yes --> F[Dangerous-call guard]
    E --> F
    F --> G[QGIS exec runs code in restrained namespace]
    G --> H[Layer created, results shown]
Loading
  1. Context Gathering: build_qgis_context() collects all layer info, CRS, fields, and available algorithms
  2. AI Processing: The LLM generates QGIS Python code based on context and user request
  3. Code Extraction: fenced ```python blocks are pulled from the AI response
  4. Safety Gate: If auto-execute is off (default), a dialog asks you to confirm; a regex guard blocks obvious destructive calls (os.system, subprocess, shutil.rmtree, eval)
  5. Execution: Code runs via exec() with a curated QGIS namespace (iface, processing, QgsProject, etc.) and print output captured
  6. Feedback: Results (new layers, processing output, errors) are displayed in the chat and logged to the QGIS message log

โš ๏ธ Security note: Code execution is not sandboxed at the Python level. Only auto-execute code from providers you trust, and keep review-confirmation enabled unless you understand the risk.


๐Ÿงช Scripts API Reference

The analysis engine in scripts/ provides programmatic access to all GeoPilot capabilities:

Module Purpose Key Functions
geoai_vector_analysis Vector GIS operations buffer_layer(), clip_layers(), spatial_join()
geoai_raster_analysis Raster processing calculate_slope(), reclassify_raster(), contour()
geoai_remote_sensing Remote sensing calculate_ndvi(), classify_landcover(), detect_change()
geoai_sci_figure SCI figures create_study_area_map(), create_classification_figure()
geoai_paper_agent Journal matching recommend_journal(), generate_cover_letter()
geoai_pipeline Workflows run_forest_disturbance(), run_urban_expansion()
geoai_report Reports generate_research_report(), generate_thesis_outline()
geoai_qgis_bootstrap QGIS init init_qgis()
geoai_gee_bridge GEE integration init_ee(), gee_export()

๐Ÿ› ๏ธ Development

Build & Package

make install    # Install to QGIS profile
make zip        # Create distributable ZIP
make clean      # Remove __pycache__

Adding a New Provider

from .base import BaseProvider, register_provider

class MyProvider(BaseProvider):
    ENV_KEY = "MY_API_KEY"
    DEFAULT_URL = "https://api.example.com/v1"
    
    def chat(self, messages, system_prompt=None, temperature=0.7, max_tokens=4096):
        # Implement API call
        return response_text

register_provider('myprovider', MyProvider,
    display_name='My Provider',
    models=['model-1', 'model-2'],
    env_key='MY_API_KEY',
    default_url='https://api.example.com/v1')

โ“ FAQ

Q: Does GeoPilot actually execute code in QGIS? A: Yes! Unlike chat-only plugins, GeoPilot runs AI-generated Python code directly in QGIS using exec(). Results appear as new layers, processed data, and visual feedback.

Q: Do I need internet? A: For cloud AI providers, yes. For offline use, install Ollama locally with models like llama3.1 or qwen2.5.

Q: Which provider is best for geospatial analysis? A: DeepSeek, Qwen, and Claude generally produce the best QGIS Python code. OpenAI GPT-4o is also excellent.

Q: Can I use it without an API key? A: Yes! Use the Ollama provider with locally installed models โ€” completely free and offline.

Q: How do I get API keys? A: See the Getting API Keys table above. Most providers offer free credits for new users.


๐Ÿ“„ License

MIT License โ€” see LICENSE.

๐Ÿ“ Citation

@software{geopilot2026,
  author = {GeoPilot Team},
  title = {GeoPilot: AI-Powered Geospatial Analysis Assistant for QGIS},
  year = {2026},
  url = {https://github.com/xingguangYan/GeoPilot}
}

โญ If you find GeoPilot useful, please star the repo!

About

AI-powered geospatial analysis assistant QGIS plugin with 20+ LLM model provider support

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages