Contextual Q&A with GeoAgent¶
GeoAgent can answer general questions using its built-in LLM — from earth science topics and natural disaster impacts to programming questions and everyday queries.
When a query asks for information or explanation rather than data retrieval or visualization, it is automatically routed to the ContextAgent for a direct LLM answer.
# %pip install geoagent
from geoagent import GeoAgent
agent = GeoAgent()
1. Earth Science Questions¶
Ask about natural phenomena, environmental topics, and earth observation science.
result = agent.chat("What is NDVI and how is it calculated?")
print(f"Intent: {result.plan.intent}")
print(f"Success: {result.success}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("How do synthetic aperture radar (SAR) satellites work?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("Explain the difference between Landsat and Sentinel-2 satellites")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
2. Natural Disaster Impact Questions¶
Ask about the impact of specific natural disasters — hurricanes, wildfires, floods, and more.
result = agent.chat("How was NYC impacted by Hurricane Sandy?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("What was the impact of Hurricane Florence 2018 in North Carolina?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat(
"How did vegetation recover after flooding in Missouri River valley 2023?"
)
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
3. Climate and Environmental Trends¶
result = agent.chat(
"What are the long-term climate trends affecting Pacific Northwest forests?"
)
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat(
"Explain the correlation between El Niño events and wildfire patterns"
)
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat(
"What is urban heat island effect and which cities are most affected?"
)
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
4. General Questions¶
GeoAgent can also handle general-purpose questions — it's not limited to earth science.
result = agent.chat("What is the STAC specification and why is it important?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("What are Cloud Optimized GeoTIFFs and why are they useful?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("What is the difference between raster and vector data in GIS?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
result = agent.chat("What Python libraries are commonly used for geospatial analysis?")
print(f"Intent: {result.plan.intent}")
print()
if result.answer_text:
print(result.answer_text)
5. Mixed Queries — Data + Explanation¶
Some queries combine data visualization with contextual information. GeoAgent handles both in one response.
# This should trigger data visualization
result = agent.chat(
"Show me Sentinel-2 imagery of the Amazon rainforest in August 2024"
)
print(f"Intent: {result.plan.intent}")
print(f"Items: {result.data.total_items if result.data else 0}")
print(f"Has answer_text: {result.answer_text is not None}")
result.map
# This should trigger explanation
result = agent.chat("What causes deforestation in the Amazon rainforest?")
print(f"Intent: {result.plan.intent}")
print(f"Has answer_text: {result.answer_text is not None}")
print()
if result.answer_text:
print(result.answer_text)
How It Works¶
GeoAgent's Planner classifies queries into intents:
| Intent | Routing | Example |
|---|---|---|
search |
Data pipeline → STAC search | "Find Sentinel-2 images of Tokyo" |
analyze |
Data pipeline → analysis | "Compute NDVI for California" |
visualize |
Data pipeline → map | "Show land cover for Denver" |
compare |
Data pipeline → comparison | "Compare forest cover 2020 vs 2024" |
explain |
ContextAgent → LLM answer | "What is NDVI?" |
monitor |
ContextAgent → LLM answer | "Track deforestation trends" |
The explain and monitor intents route directly to the ContextAgent, which uses the LLM to provide informative answers.