GeoPandas AI is an extension of GeoPandas allowing you to interact with your spatial data in natural language.
Project description
GeoPandas AI
GeoPandas AI is a powerful Python library that brings natural language processing capabilities to your geospatial data analysis workflow. It allows you to interact with GeoDataFrames using natural language queries, making geospatial analysis more accessible and intuitive. It is both suitable for Jupyter notebooks and Python scripts or packages.
Features
- Natural language interaction with GeoDataFrames
- Support for multiple LLM providers through LiteLLM
- Built-in support for Jupyter notebooks
- Extensible and configurable.
Installation
pip install geopandas-ai
Quick Start
GeoPandas AI is designed to work seamlessly with GeoPandas. Most function available in GeoPandas are also available in GeoPandas AI.
Example Usage 1
import geopandasai as gpdai
gdfai = gpdai.read_file("path/to/your/geodatafile.geojson")
figure = gdfai.chat("Plot the data")
figure = gdfai.improve("Change the title to something more selling and add a basemap")
Example Usage 2
import geopandas as gpd
import geopandasai as gpdai
gdf = gpd.read_file("path/to/your/geodatafile.geojson")
# Convert GeoDataFrame to GeoDataFrameAI, provide a description for the data to provide context to the LLM
gdfai = gpdai.GeoDataFrameAI(gdf, description='A GeoDataFrame containing geospatial data, the fields are..')
# Use the chat method to interact with the GeoDataFrame, syntax sugar to avoid having to go to next line and
# call gdfai.improve again.
gdfai.chat("Plot the data").improve("Change the title to something more selling and add a basemap")
Example Usage 3 (Advanced parameters)
import geopandasai as gpdai
gdfai = gpdai.read_file("path/to/your/geodatafile.geojson")
gdfai.set_description("A GeoDataFrame containing geospatial data, the fields are...")
a_second_df = gpdai.read_file("path/to/another/geodatafile.geojson")
a_second_df.set_description("A second GeoDataFrame containing additional geospatial data.")
value = gdfai.chat(
"Number of clusters in the data",
a_second_df, # Additional GeoDataFrame to use in the query, can add one or more GeoDataFrames
provided_libraries=['scikit-learn', 'numpy'], # Additional libraries that can be used in the generated code
return_type=int
)
value = gdfai.improve(
"Smaller clusters",
)
# Once happy with the result, you can save the modified GeoDataFrame
gdfai.inject(function_name="find_clusters")
# Then replace the above code with
import ai
ai.find_clusters(
gdfai, # The GeoDataFrame to operate on
a_second_df, # Additional GeoDataFrame to use in the query
)
)
⚙️ Configuration: Customizing GeoPandasAI
GeoPandasAI uses a dependency-injected configuration system for managing execution, injection, caching, and LLM-related behavior. This allows you to swap components easily for custom behavior or testing.
You can configure the lite_llm_config by using the same arguments as the ones you would provide to the completion function of LiteLLM.
✨ Update the Configuration
Use update_geopandasai_config(...) to override any subset of the configuration:
from geopandasai import update_geopandasai_config
from geopandasai.external.cache.backend.file_system import FileSystemCacheBackend
from geopandasai.services.description.descriptor.public import PublicDataDescriptor
from geopandasai.services.inject.injectors.print_inject import PrintCodeInjector
from geopandasai.services.code.executor import TrustedCodeExecutor, UntrustedCodeExecutor
update_geopandasai_config(
lite_llm_config={"model": "your-llm-config"}, # dict | None
libraries=["pandas", "geopandas", "matplotlib"], # List[str] | None
cache_backend=FileSystemCacheBackend(), # ACacheBackend | None
descriptor=PublicDataDescriptor(), # ADescriptor | None
return_types={int, float}, # Set[type] | None
injector=PrintCodeInjector(), # ACodeInjector | None
executor=TrustedCodeExecutor(), # ACodeExecutor | None (or UntrustedCodeExecutor())
)
🔧 Access the Current Configuration
from geopandasai import get_geopandasai_config
config = get_geopandasai_config()
print(config.libraries)
Requirements
- Python 3.8+
- GeoPandas
- LiteLLM
- Matplotlib
- Folium
- Contextily
License
MIT + Commercial Platform Restriction (see LICENSE.md)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geopandas_ai-0.0.25.tar.gz.
File metadata
- Download URL: geopandas_ai-0.0.25.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
550579daa81077f20cbabc4bb56ad02d9b8658c44e1cceaaef85e6148eb3c8d2
|
|
| MD5 |
c7e14ff1a7e6983855a77c0623d0e827
|
|
| BLAKE2b-256 |
3ce76a9d6e9fb8522de70abccb6443b0e5d36ba2b70e0508d640a29b315408db
|
Provenance
The following attestation bundles were made for geopandas_ai-0.0.25.tar.gz:
Publisher:
python-publish.yml on GaspardMerten/geopandas-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geopandas_ai-0.0.25.tar.gz -
Subject digest:
550579daa81077f20cbabc4bb56ad02d9b8658c44e1cceaaef85e6148eb3c8d2 - Sigstore transparency entry: 225752206
- Sigstore integration time:
-
Permalink:
GaspardMerten/geopandas-ai@a85f1153ad7587a6a36d62edec882b697253ad29 -
Branch / Tag:
refs/tags/v0.0.25 - Owner: https://github.com/GaspardMerten
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a85f1153ad7587a6a36d62edec882b697253ad29 -
Trigger Event:
push
-
Statement type:
File details
Details for the file geopandas_ai-0.0.25-py3-none-any.whl.
File metadata
- Download URL: geopandas_ai-0.0.25-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27983ec617dbca4be6f49e2ca91c77b144d459b9850b70733777329e8cfcf13f
|
|
| MD5 |
2648af3ffc891838704edb566e5479e9
|
|
| BLAKE2b-256 |
6a34d4d0d6b525ee93a8224a2dc4eb310f53a46af885ec20c521d91036ce0736
|
Provenance
The following attestation bundles were made for geopandas_ai-0.0.25-py3-none-any.whl:
Publisher:
python-publish.yml on GaspardMerten/geopandas-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geopandas_ai-0.0.25-py3-none-any.whl -
Subject digest:
27983ec617dbca4be6f49e2ca91c77b144d459b9850b70733777329e8cfcf13f - Sigstore transparency entry: 225752209
- Sigstore integration time:
-
Permalink:
GaspardMerten/geopandas-ai@a85f1153ad7587a6a36d62edec882b697253ad29 -
Branch / Tag:
refs/tags/v0.0.25 - Owner: https://github.com/GaspardMerten
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a85f1153ad7587a6a36d62edec882b697253ad29 -
Trigger Event:
push
-
Statement type: