Skip to main content

GeoPandas-AI

GeoPandas-AI Logo

GeoPandas-AI is an open-source Python library that enhances geospatial data analysis by turning the GeoDataFrame into a conversational, intelligent assistant. It seamlessly integrates large language models (LLMs) into the geospatial workflow, enabling natural language interaction, iterative refinement, caching, and code generation directly within your Python environment.

PyPI version
arXiv
Documentation

🌍 Motivation

Geospatial data is key to solving complex problems in urban planning, environmental science, and infrastructure development. But tools like GeoPandas require familiarity with both GIS concepts and Python-based workflows.

GeoPandas-AI lowers this barrier by:

  • Embedding conversational AI directly into GeoDataFrame
  • Enabling plain-language queries and refinements
  • Supporting reproducible, scriptable workflows with AI-assisted code
  • Caching results to avoid redundant LLM calls

This bridges human interaction with geospatial analysis in a seamless and stateful way.


🧠 What’s New?

Based on the arXiv preprint, GeoPandas-AI introduces:

  • ✅ A stateful, LLM-augmented GeoDataFrameAI class
  • .chat() and .improve() methods for language-based querying and iteration
  • ✅ Built-in caching: repeated prompts reuse cached results (no extra LLM calls)
  • ✅ Full compatibility with existing GeoDataFrame workflows
  • ✅ Modular backends for execution, injection, caching, and LLM calls
  • ✅ A vision of conversational programming for geospatial developers

Read the paper: GeoPandas-AI: A Smart Class Bringing LLM as Stateful AI Code Assistant


⚙️ Installation

pip install geopandas-ai

Python 3.8+ required.


🚀 Quick Start

Example 1: Read and visualize spatial data interactively

import geopandasai as gpdai

gdfai = gpdai.read_file("cities.geojson")
gdfai.chat("Plot the cities by population")
gdfai.improve("Add a title and a basemap")

Example 2: Wrap an existing GeoDataFrame

import geopandas as gpd
from geopandasai import GeoDataFrameAI

gdf = gpd.read_file("parks.geojson")
gdfai = GeoDataFrameAI(
    gdf,
    description="City parks with name, area, and geometry"
)

gdfai.chat("Show the largest 5 parks")

Example 3: Work with multiple dataframes

a = gpdai.read_file("zones.geojson")
b = gpdai.read_file("reference.geojson")

a.set_description("Zoning polygons for city planning")
b.set_description("Reference dataset with official labels")

a.chat(
    "Cluster the zones into 3 groups based on geometry size",
    b,
    provided_libraries=["scikit-learn", "numpy"],
    return_type=int
)

🔧 Configuration & Caching

GeoPandas-AI uses a flexible dependency-injection architecture (via dependency_injector) to manage:

  • LiteLLM settings
  • Cache backend (memoizes .chat() and .improve() calls)
  • Code executor (trusted or sandboxed)
  • Code injector
  • Data descriptor
  • Allowed return types

Built-in caching

By default, responses and generated code are cached on disk:

from geopandasai.external.cache.backend.file_system import FileSystemCacheBackend

# Default writes to `.gpd_cache/`

Any repeated prompt or improvement will reuse cached results, saving tokens and accelerating workflows.

Customizing configuration

Override defaults with update_geopandasai_config():

from geopandasai import update_geopandasai_config
from geopandasai.external.cache.backend.file_system import FileSystemCacheBackend
from geopandasai.services.inject.injectors.print_inject import PrintCodeInjector
from geopandasai.services.code.executor import TrustedCodeExecutor

update_geopandasai_config(
    cache_backend=FileSystemCacheBackend(cache_dir=".gpd_cache"),
    executor=TrustedCodeExecutor(),
    injector=PrintCodeInjector(),
    libraries=[
      "pandas",
      "matplotlib.pyplot",
      "folium",
      "geopandas",
      "contextily",
    ],
)

Forcing fresh LLM calls

To clear all memory and cache for a fresh start:

gdfai.reset()

📚 Learn More


📄 Citation

If you use GeoPandas-AI in academic work, please cite:

@misc{merten2025geopandasaismartclassbringing,
  title={GeoPandas-AI: A Smart Class Bringing LLM as Stateful AI Code Assistant}, 
  author={Gaspard Merten and Gilles Dejaegere and Mahmoud Sakr},
  year={2025},
  eprint={2506.11781},
  archivePrefix={arXiv},
  primaryClass={cs.HC},
  url={https://arxiv.org/abs/2506.11781}, 
}

🖎 Authors

This project is a product of the Université Libre de Bruxelles (ULB), and most notably the Data Science and Engineering Lab. It is maintained by:


🪪 License

MIT License – see LICENSE for details.

GeoPandas-AI: Making geospatial analysis conversational, intelligent, and reproducible.

Release files for geopandas-ai 0.0.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geopandas-ai 0.0.36
File Size Uploaded
geopandas_ai-0.0.36.tar.gz 28.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for geopandas-ai 0.0.36
File Interpreter ABI Platform
geopandas_ai-0.0.36-py3-none-any.whl Python 3 none any Details

Total release size: 68.8 kB

Release files / geopandas_ai-0.0.36.tar.gz

Download URL geopandas_ai-0.0.36.tar.gz
Size 28.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8f47263ff4bf5a73517d3112cbeb71aefb2f077d41f10293e02d901d16c5b3aa
BLAKE2b-256 checksum
How to use checksums
9c102100e7f1c5acdd002c83dd670923b69764334c88181b0bcc05e980051b55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.

Transparency log

Release files / geopandas_ai-0.0.36-py3-none-any.whl

Download URL geopandas_ai-0.0.36-py3-none-any.whl
Size 40.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4586273cffc06594ca50da46197f933a0d6300a53defdec97fe879129899f784
BLAKE2b-256 checksum
How to use checksums
429020da3efe0bfb2e44218eeedf657bcd853aecd23f71984d8dd29568b49ff0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page