Spatial Analysis Agent in QGIS: Analyze Spatial Data with AI and Natural Language
- Xuebin Wei

- Aug 5
- 2 min read
This tutorial demonstrates how to use the Spatial Analysis Agent plugin in QGIS to perform spatial data analysis using natural language powered by AI. With this tool, users can describe tasks in natural language, and the plugin will generate geoprocessing workflows. While no advanced coding is required, some basic programming and GIS knowledge are necessary to understand and apply the outputs effectively.
Introduction to Natural Language Spatial Analysis
The Spatial Analysis Agent integrates QGIS with OpenAI’s GPT models, including GPT-o3, known for its reasoning capabilities. This plugin translates natural language prompts into spatial workflows, making it easier to conduct tasks such as creating symbology, performing temporal aggregation, and generating movement paths.

Installing and Configuring the Plugin
Open QGIS.
Navigate to Plugins > Manage and Install Plugins.
Search for SpatialAnalysisAgent and install it.
Launch the plugin and open the Settings tab.
Provide your OpenAI API key.
Select a model (default: gpt-4o) and define a workspace directory.

Common Use Cases
Styling Layers by Attribute
Prompt: "Assign unique colors to the GPS layer based on the name field."The plugin automatically generates a styling workflow based on unique attribute values, such as "home," "work," and "gym."

Summarizing Temporal Patterns
Prompt: "Count total hours spent at each location and display the results in a bar chart."Using timestamp data, the plugin calculates durations per location and produces a visual summary.

Creating Movement Paths
Prompt: "Create movement paths from the GPS points."GPT-4o interprets sequential data and generates line features that represent spatial movement over time.

Attempting an Open-Ended Spatial Question
Prompt: "Analyze spatial-temporal movement patterns."This is a more complex, open-ended task that pushes the model's reasoning limits. In the video, this prompt did not produce meaningful output. Still, reviewing the generated code may offer insight or inspiration for refining your own analysis.
Best Practices for Effective Prompts
Use precise layer and field names in your prompt.
Examine generated code to understand workflows or troubleshoot issues.
Combine with manual GIS techniques to validate or extend results.
Benefits of Using the Spatial Analysis Agent
This plugin supports AI-assisted geoprocessing in QGIS, enabling faster prototyping, reducing manual scripting, and enhancing learning. It is especially useful for:
GIS students and educators
Analysts working with spatial and temporal data
Users exploring AI-driven GIS workflows
Further Resources
GitHub Repository: https://github.com/Teakinboyewa/SpatialAnalysisAgent
QGIS Official Website: https://www.qgis.org
Free GIS Course: https://www.lbsocial.net/challenge-page/gis
Comments