Skip to content

Siv4kumaru/mapman

Repository files navigation

MapMan: AI-Powered Geospatial Analysis

alt text

Deployed at : link 🔗

MapMan is a powerful and intuitive web application that allows you to perform complex geospatial analysis using natural language queries. Simply type in what you're looking for, and MapMan will generate and display the corresponding map.

MapMan was developed for the Bharatiya Antariksh Hackathon 2025 (ISRO Challenge) to demonstrate how Large Language Models (LLMs) can orchestrate complex geospatial analysis pipelines automatically. While platforms like Google Earth Engine (GEE) are extremely powerful, they require GIS expertise and manual coding. MapMan solves this by combining LangChain + Python geospatial libraries to translate natural language into multi-step workflows, executed transparently with Chain-of-Thought reasoning.

Features

  • Natural Language Queries: Ask for maps in plain English (e.g., "flood risk map of chennai", "land cover map of Delhi").
  • AI-Powered Workflow Generation: MapMan uses LangChain with Gemini Flash to dynamically generate the necessary steps to fulfill your request.
  • Google Earth Engine Integration: Leverages the power of Google Earth Engine for large-scale geospatial data processing.
  • Interactive Maps: Explore the generated maps with panning, zooming, and layer controls.
  • Extensible Functionality: The core functions are organized in a registry, making it easy to add new geospatial analysis capabilities.
  • Transparent Reasoning: Displays the LLM's reasoning (Chain-of-Thought) alongside the map, providing insight into the workflow.

Architecture

MapMan's architecture is designed to be modular and extensible. It consists of three main components:

alt text alt text

  1. User Interface (Streamlit): The frontend of the application, built with Streamlit. It captures the user's query and displays the resulting map and the LLM's reasoning.
  2. Workflow Generator (LLM): This component uses LangChain with Gemini Flash to parse the user's query and generate a structured JSON workflow.
  3. Workflow Executor (Python Sandbox): This is the backend that executes the generated workflow. It uses a custom execute_workflow() runner with Python's inspect to resolve arguments across steps.
  4. Google Earth Engine: The primary data source and processing engine.

Workflow

The following diagram illustrates the workflow from user query to map display:

sequenceDiagram
    participant User
    participant App (Streamlit)
    participant Workflow Generator
    participant Workflow Executor
    participant Google Earth Engine

    User->>App: Enters a query (e.g., "flood risk map of chennai")
    App->>Workflow Generator: Sends the user's query
    Workflow Generator->>Workflow Executor: Returns a JSON workflow
    Workflow Executor->>Google Earth Engine: Executes the workflow steps
    Google Earth Engine-->>Workflow Executor: Returns processed data
    Workflow Executor-->>App: Returns the final map object
    App-->>User: Displays the interactive map
Loading

Geospatial Processing

For geospatial processing, MapMan integrates Google Earth Engine (ee), geemap, and folium for interactive maps.

  • Flood risk workflows use Sentinel-1 SAR data and JRC surface water occurrence to delineate hazard zones at country, state, or district levels.
  • Land cover workflows use ESA WorldCover 2021 imagery with custom color palettes and legends.

Deployment

To ensure deployment readiness, MapMan is fully containerized with Docker and integrated with Streamlit for local/edge execution. Cloud deployment is ongoing, and temporarily Overview deployed on render free service. with testing of scaling strategies for GEE authentication and persistent vector data storage.

Future Work

The current architecture is designed for future scalability. As the number of tools grows, Retrieval-Augmented Generation (RAG) will be implemented to reduce LLM hallucination and improve tool discovery. Additionally, the system is designed to integrate GeoJSON maps from other sites to perform operations on them in the future.

Setup and Installation

  1. Clone the repository:

    git clone https://github.com/your-username/mapman.git
    cd mapman
  2. Create a virtual environment and install dependencies:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    pip install -r req.txt
  3. Set up Google Earth Engine credentials:

    • Follow the instructions here to create a service account and download the JSON key file.
    • now base encrpyt the json file and paste it inside .env file following the structure of .env.example
    • Set the GEE_SERVICE_ACCOUNT environment variable to your service account email address.
  4. Set up your Google Generative AI API key:

    • Get your API key from Google AI Studio.
    • Create a .env file in the root of the project and add the following line:
      GOOGLE_API_KEY="your-api-key"
      

Usage

To run the application, use the following command:

streamlit run app.py

This will open the application in your web browser. You can then enter your queries in the text box and see the results on the map.

Key Files

  • app.py: The main Streamlit application file.
  • _work_flow_gen.py: Generates the workflow using a large language model.
  • python_sandbox.py: Executes the workflow and interacts with Google Earth Engine.
  • function_registry.json: A JSON file that defines the available functions for the workflow.
  • sys_prompt_temp.txt: The system prompt that instructs the LLM on how to generate the workflow.
  • req.txt: A list of all the Python dependencies.
  • .env: Your Google Generative AI API key and gcp components needed for gee auth.
  • .env.example: example of what your .env file formatted variables should be

About

Gee powered flood risk analysis and land cover generator , powered by gemini

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors