STAC agents
STAC Agent - Natural Language Satellite Imagery Search
This notebook demonstrates how to use the STAC (SpatioTemporal Asset Catalog) Agent to search for satellite and aerial imagery using natural language queries.
The STAC Agent can:
- Understand natural language queries about geospatial data
- Search the Microsoft Planetary Computer STAC catalog
- Convert location names to coordinates
- Find appropriate collections and items
- Return structured results with item IDs, URLs, and metadata
Uncomment the following line to install geoai if needed.
Installation¶
In [ ]:
Copied!
# %pip install "geoai[agents]"
# %pip install "geoai[agents]"
Import libraries¶
In [ ]:
Copied!
import json
from geoai import Map
from geoai.agents import (
STACAgent,
STACTools,
create_ollama_model,
create_openai_model,
create_anthropic_model,
create_bedrock_model,
)
import json
from geoai import Map
from geoai.agents import (
STACAgent,
STACTools,
create_ollama_model,
create_openai_model,
create_anthropic_model,
create_bedrock_model,
)
Create a model¶
You can create a model with the following functions:
create_ollama_model
: Create a model using Ollama. You will need to install Ollama) separately and pull the model you want to use, such asllama3.1
.create_openai_model
: Create a model using OpenAI. You will need an OpenAI API key. Set it in theOPENAI_API_KEY
environment variable.create_anthropic_model
: Create a model using Anthropic. You will need an Anthropic API key. Set it in theANTHROPIC_API_KEY
environment variable.create_bedrock_model
: Create a model using Bedrock. You will need an AWS account and theAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environment variables set.
In [ ]:
Copied!
model = create_ollama_model(model="llama3.1")
model = create_ollama_model(model="llama3.1")
Call STAC tools directly¶
In [ ]:
Copied!
tools = STACTools()
tools = STACTools()
In [ ]:
Copied!
tools.list_collections()
tools.list_collections()
In [ ]:
Copied!
tools.list_collections(filter_keyword="landsat")
tools.list_collections(filter_keyword="landsat")
In [ ]:
Copied!
agent = STACAgent(model=model)
agent = STACAgent(model=model)
In [ ]:
Copied!
result = agent.ask("Find Sentinel-2 imagery over San Francisco in August 2025")
json.loads(result)
result = agent.ask("Find Sentinel-2 imagery over San Francisco in August 2025")
json.loads(result)
Show the agent UI¶
In [ ]:
Copied!
m = Map(center=[-100, 40], zoom=3, projection="globe")
agent = STACAgent(model=model, map_instance=m)
agent.show_ui()
m = Map(center=[-100, 40], zoom=3, projection="globe")
agent = STACAgent(model=model, map_instance=m)
agent.show_ui()