An intelligent GIS automation system that leverages AI (Google Gemini) to automatically generate ArcGIS Pro spatial analysis workflows from natural language task descriptions.
Spatial Analysis Workflow Agent transforms user-input spatial analysis task descriptions into structured ArcGIS Pro workflows. By combining natural language processing with GIS expertise, this system enables both GIS professionals and non-specialists to create complex spatial analysis pipelines with high efficiency.
- Natural Language Interface: Describe your spatial analysis tasks in plain English
- AI-Powered Workflow Generation: Automatically generates valid ArcGIS Pro workflows using Google Gemini
- Shapefile Support: Upload and parse geographic datasets in shapefile format
- Structured Output: Generates workflows in both plain steps summary and strict JSON Schema format
- Quality Checks: Includes automated validation rules for each workflow step
- Web Interface: Interactive Streamlit-based UI for easy access and testing
- Model Evaluation: Score and benchmark AI accuracy to compare and select the best performing model
spatial-analysis-agent/
βββ src/
β βββ streamlit_app.py # Main web interface
β βββ prompts.py # Gemini prompt templates and system instructions
β βββ schema.json # JSON Schema for workflow validation
β βββ main.py # Main entry point
β βββ server.py # API server implementation
β βββ gemini_test.py # Gemini API testing utilities
β βββ agent/
β β βββ data_catalog_dbf.py # DBF file catalog utilities
β βββ eval/
β β βββ auto_score.py # Evaluation and scoring module
β βββ validation/ # Validation utilities
βββ data/
β βββ tasks/ # Sample task descriptions
β βββ pred/ # Prediction workflows results
β βββ truth/ # Ground truth workflows
β βββ reports/ # Evaluation reports
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (API keys)
βββ README.md # This file
- Python 3.8 or higher
- Virtual environment manager (venv or conda)
- Google Gemini API key
-
Clone the repository
git clone <repository-url> cd spatial-analysis-agent
-
Create and activate virtual environment
python -m venv .venv-spatial source .venv-spatial/bin/activate # On Windows: .venv-spatial\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
Create a
.envfile in the project root:GEMINI_API_KEY=your_gemini_api_key_here
Launch the interactive web application:
cd src
streamlit run streamlit_app.pyThe app will open in your browser (typically at http://localhost:8501).
- Data Tab
- Upload a shapefile archive (.zip containing .shp, .shx, .dbf, .prj files)
- System automatically extracts and displays layer fields
- View sample attribute rows
- Agent Tab
The system currently supports the following ArcGIS Pro tools:
- Clip
- Buffer
- Spatial Join
- Intersect
- Calculate Field
- Add Field
- Calculate Geometry Attributes
- Kernel Density
- Feature To Point
- Calculate Distance Band from Neighbor Count
- Select features using attributes
Tools can be extended by modifying ARCGIS_TOOL_LIST in prompts.py.
The Gemini model operates under strict guidelines defined in SYSTEM_INSTRUCTION:
- Tool Restriction: Only uses tools from the list
- Logic Coherence: Output of step S(n) becomes input for step S(n+1)
- Coordinate System Handling: Assumes projected coordinate systems by default
- JSON Compliance: All outputs must be valid JSON
- Quality Assurance: Each step includes quality checks
When task descriptions are incomplete:
- The system documents assumptions in the
assumptionsarray - It generates clarifying questions in the
clarifying_questionsarray - It continues generating workflows rather than failing
Run the test suite:
python src/gemini_test.pyEvaluate workflow generation quality:
python src/eval/auto_score.pyIf running the server:
python src/server.pyRefer to server.py for available endpoints.
data/tasks/: Sample task definitionsdata/truth/: Ground truth workflows for validationdata/pred/: Model-generated predictions for evaluationdata/reports/: Analysis reports and metrics
- Multi-step workflow validation and execution
- Integration with ArcGIS Online
- Support for more GIS tools and operations
See LICENSE file for details.
Last Updated: January 2026
Version: 1.0.0


