GeoAI Documentation

repository·main·Indexed 25 days ago

https://github.com/opengeos/geoai

A comprehensive Python framework (geoai-py v0.42.0) for bridging artificial intelligence and geospatial data analysis. It provides tools for processing satellite imagery, aerial photographs, and vector data using deep learning models. The ecosystem includes the cli-anything-geoai CLI for raster/vector operations and segmentation, a Model Context Protocol (MCP) server for AI agent integration, and a QGIS plugin for visual geospatial AI analysis.

Tokens
128.6K
Snippets
538
Records
726
Agent score
82%

What's inside GeoAI

  1. Overview of GeoAI capabilities

    main

    GeoAI is a Python package that bridges artificial intelligence and geospatial data analysis. It provides a unified framework for processing satellite imagery, aerial photographs, and vector data using deep learning models.

    Core capabilities include:

    • Data Acquisition: Interactive and programmatic search/download of remote sensing imagery.
    • Dataset Preparation: Automated generation of image chips and labels.
    • Model Training: Support for classification, detection, and segmentation tasks.
    • Inference: Pipelines for applying trained models to new geospatial datasets.
    • Visualization: Interactive visualization via Leafmap and MapLibre integration.
    • QGIS Integration: A dedicated GeoAI plugin for running AI workflows within the QGIS desktop environment without writing code.
  2. Use the moondream module for geospatial image analysis

    main

    The geoai.moondream module integrates the Moondream vision language model (VLM) to enable natural language querying of satellite and aerial imagery.

    Key capabilities include:

    • Image Captioning: Generating text descriptions of geospatial imagery.
    • Visual Question Answering (VQA): Answering specific questions about the content of an image using natural language.
    • Object Grounding: Identifying and locating objects within an image.
    • Point-based Object Detection: Detecting objects at specific points, with support for sliding window processing to handle large rasters that exceed the model's input resolution.
  3. Use the vllm_geo module for geospatial image analysis

    main

    The vllm_geo module integrates open-source vision language models (VLMs) served via vLLM to perform geospatial image analysis. It is designed for high-throughput, self-hosted inference using vLLM's PagedAttention.

    Key capabilities include:

    • Image Captioning: Generating textual descriptions of geospatial imagery.
    • Visual Question Answering (VQA): Answering specific questions about an image.
    • Prompt-based Object Detection: Identifying objects within an image using text prompts.
    • Sliding Window Support: Handling large rasters by processing them in windows.

    Supported modes:

    • Server Mode: Connects to a running vLLM instance started via vllm serve <model>.
    • In-process Mode: Runs inference locally by setting offline=True.
  4. Use the onnx module for geospatial model export and inference

    main
    The geoai.onnx module provides capabilities to export trained PyTorch models to the ONNX (Open Neural Network Exchange) format and perform inference using those exported models. This allows for optimized deployment across various hardware platforms and runtime environments without needing the original PyTorch training framework.
  5. Use the train module for geospatial model training

    main

    The geoai.train module provides end-to-end pipelines for training geospatial machine learning models. It supports object detection, instance segmentation, and semantic segmentation on geospatial imagery.

    Key capabilities include:

    • Dataset Management: Preparation and geospatial-aware data loading.
    • Augmentation: Integrated data augmentation pipelines.
    • Training & Evaluation: Managed training loops and evaluation metrics.
    • Model Export: Exporting trained models for deployment.

    Supported architectures include Mask R-CNN, Faster R-CNN, and various U-Net variants.

  6. Generate geospatial embeddings with the embeddings module

    main
    The geoai.embeddings module generates dense feature representations from satellite and aerial imagery using TorchGeo-based foundation models. These embeddings can be used for tasks such as similarity search, clustering, change detection, and downstream classification without requiring task-specific fine-tuning.
  7. Use the ESRGAN module for image super-resolution

    main
    The geoai.esrgan module provides capabilities for image super-resolution using the Enhanced Super-Resolution Generative Adversarial Networks (ESRGAN) model. This allows for increasing the resolution and detail of geospatial imagery.
  8. Manage GPU Memory and Plugin Updates

    main

    Clear GPU Memory

    To prevent out-of-memory errors when switching between large models, click the GPU button in the GeoAI toolbar. This releases GPU memory from all loaded models and clears the CUDA cache.

    Update the Plugin

    To check for updates:

    1. Go to GeoAI menu → Check for Updates....
    2. Click Check for Updates to fetch info from GitHub.
    3. If an update is available, click Download and Install Update.
    4. Restart QGIS to apply the update.
  9. Use the Tree Segmentation Panel (DeepForest)

    main

    The Tree Segmentation panel uses pretrained DeepForest models to detect objects like tree crowns, birds, livestock, nests, and dead trees in remote sensing imagery.

    Supported Models

    • Tree Crown Detection: weecology/deepforest-tree (Detects individual tree crowns in RGB)
    • Bird Detection: weecology/deepforest-bird
    • Livestock Detection: weecology/deepforest-livestock
    • Nest Detection: weecology/everglades-nest-detection
    • Dead Tree Detection: weecology/cropmodel-deadtrees

    Workflow

    1. Load Model: Open the panel via the GeoAI toolbar or GeoAI menu → Tree Segmentation. In the Model tab, select a model, configure the device (auto, cuda, or cpu), and click Load Model. Select your image via Set Image from Layer or Set Image from File.
    2. Predict: In the Predict tab, choose between Single Image (small images) or Large Tile (high-resolution imagery). For Large Tile mode, configure:
      • Patch Size: Default 400px (try 400-800px for 0.1m data).
      • Patch Overlap: Default 0.25.
      • IoU Threshold: Default 0.15.
      • Dataloader Strategy: single, batch, or window.
      • Score Threshold: Default 0.3.
    3. Export: In the Output tab, save results as Vector (GeoPackage, Shapefile, or GeoJSON) or Raster (GeoTIFF). You can also export training data in PASCAL_VOC, COCO, or YOLO formats.
  10. Use the Segment Anything Panel (SamGeo)

    main

    The Segment Anything panel provides object segmentation using the SAM model.

    Workflow

    1. Model Setup: Open via the GeoAI toolbar or GeoAI menu → Segment Anything. In the Model tab, select a version (SamGeo3/SAM3, SamGeo2/SAM2, or SamGeo/SAM1), configure the backend (meta or transformers) and device (auto, cuda, cpu), then click Load Model.
    2. Segmentation Methods:
      • Text Tab: Enter text prompts (e.g., "tree, building").
      • Interactive Tab: Use Add Foreground Points, Add Background Points, or Draw Box on the map, then click Segment by Points or Segment by Box.
      • Batch Tab: Add multiple points interactively or load from a vector file/layer.
    3. Output: Select format (Raster GeoTIFF, Vector GeoPackage, or Vector Shapefile). For vector output, you can enable Regularize polygons (orthogonalize) and set Epsilon (simplification tolerance) and Min Area.
  11. Access and authenticate SAM 3

    main

    To use SAM 3, you must first request access via the Hugging Face form: https://huggingface.co/facebook/sam3.

    Once approved, authenticate and download the model within your Pixi environment:

    pixi run hf auth login
    pixi run hf download facebook/sam3

    Requirement: SAM 3 requires an NVIDIA GPU with CUDA support. It will fail on CPU-only systems with the error: Failed to load model: Torch not compiled with CUDA enabled.

  12. Use cli-anything-geoai one-shot commands

    main

    The cli-anything-geoai CLI provides several one-shot commands for geospatial analysis. Use the --json flag to get machine-readable output suitable for AI agents.

    Raster Operations

    • Info: cli-anything-geoai raster info <image.tif>
    • Statistics: cli-anything-geoai raster stats <image.tif> --band 1

    Segmentation

    • SAM Segmentation: cli-anything-geoai segment sam <image.tif> -o <mask.tif>
    • Text-prompted (Grounded-SAM): cli-anything-geoai segment grounded-sam <image.tif> -o <mask.tif> -p "<prompt>"

    Detection & Change Detection

    • Object Detection: cli-anything-geoai detect run <image.tif> -m <model.pth> -n <count> -ov <detections.geojson>
    • Change Detection: cli-anything-geoai change detect <before.tif> <after.tif> -o <changes.tif>

    Data Discovery

    • Download NAIP: cli-anything-geoai data download naip --bbox "<bbox>" -o <output.tif>
    • Search Satellite: cli-anything-geoai data search --bbox "<bbox>" -c <collection>