Skip to content
Back to journal
Machine Learning 11 min read 5 December 2024 Sheece Gardezi

SAM2 in production: segmenting satellite imagery at scale

Geo-SAM2 and samgeo turn Meta's foundation model into a production remote sensing tool. Zero-shot building extraction, crop boundaries, and flood mapping without training data.

SAM2SegmentationRemote SensingComputer Vision

Meta's SAM2 (August 2024) segments any object in any image from a single point click -- in milliseconds after one-time encoding. For remote sensing, the Hiera backbone provides multi-scale, high-resolution features that handle the spectral and spatial characteristics of satellite imagery far better than the original SAM. Geo-SAM2 brings this to QGIS with CPU-viable prompt inference. samgeo automates batch segmentation with georeferenced vector output. Both are production-ready today.

Three SAM2 improvements that matter for remote sensing

SAM (2023) proved a single model could segment any object from point/box prompts. But it was trained on natural images and struggled with satellite imagery's unique characteristics -- spectral bands, overhead perspective, ambiguous boundaries at landscape transitions.

SAM2 addresses this with three changes: the Hiera backbone produces multi-scale, high-resolution features critical for small objects in satellite scenes. Streaming memory enables temporal consistency for change detection across image sequences. Zero-shot generalization improved significantly on out-of-domain imagery without fine-tuning.

SAM2 uses a transformer architecture with streaming memory. This allows it to process video frames one at a time while storing information about segmented objects, enabling temporal consistency that's crucial for change detection workflows.
Meta AI Research

Geo-SAM2: encode once, click to segment in QGIS

Geo-SAM2 decouples image encoding (computationally intensive, runs once per raster) from prompt-based inference (millisecond-speed, runs on CPU). After encoding, operators click points to segment buildings, fields, water bodies, or any other features interactively.

Geo-SAM2 technical features

Multi-scale feature support

Leverages both image_embed and high_res_feats for detailed mask generation

Large image handling

Automatically splits large rasters into 1024×1024 patches with edge-adaptive cropping

Flexible spectral input

Supports 1-3 bands (grayscale, RGB, spectral indices, SAR)

CRS integration

Fully integrated with QGIS coordinate reference systems

CPU-viable inference

Prompt-based inference runs on modest hardware after encoding

samgeo: automated batch segmentation with georeferenced output

For programmatic workflows, Dr. Qiusheng Wu's samgeo package wraps SAM2 with geospatial awareness -- handling CRS, tiling large images, and converting segments to georeferenced vector polygons automatically.

samgeo_example.py
from samgeo import SamGeo

# Initialize with SAM2 model
sam = SamGeo(
    model_type="vit_h",
    checkpoint="sam2_hiera_large.pt",
    automatic=True
)

# Segment satellite image
sam.generate(
    source="sentinel2_rgb.tif",
    output="segmented.tif",
    batch=True,
    foreground=True,
    unique=True
)

Five production use cases

Where SAM2 delivers today

  • Building footprint extraction — Interactive correction of OSM data for rural areas
  • Agricultural field delineation — Rapid mapping of parcel boundaries from high-res imagery
  • Water body mapping — Flood extent extraction with minimal training data
  • Solar panel detection — Identifying rooftop installations for energy audits
  • Road network extraction — Tracing unpaved roads in developing regions

Ambiguous boundaries and the GeoFM + SAM2 hybrid

SAM2 struggles with ambiguous boundaries common in natural landscapes -- where does wetland end and forest begin? It also lacks semantic understanding: it segments objects without knowing what they are.

The emerging best practice: use a GeoFM like Clay or a trained classifier to identify what is in the scene, then apply SAM2 for precise boundary delineation. Classification provides the "what"; SAM2 provides the "where, exactly."

Human-in-the-loop delivers the best results

SAM2 is a productivity multiplier, not an autonomous system. Extracting precise polygons with a few clicks -- instead of painstaking manual digitization or multi-day model training -- changes the economics of spatial data production.

The best results come from human-in-the-loop workflows: operators use SAM2 to draft features, then refine boundaries with domain knowledge. SAM2 excels at following edges. Humans excel at knowing which edges matter.

Next step

Have a project in mind?

Tell us where you need to get to. We'll map the route — scope, timeline, and a fixed price — in a free 30-minute consultation.

Get a free consultation Replies within 1 business day