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.
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.
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.
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.
References & Further Reading
Geo-SAM2 GitHub Repository
QGIS plugin for interactive remote sensing segmentation
https://github.com/wenhwu/Geo-SAM2
segment-geospatial (samgeo) Documentation
Python package for SAM-based geospatial segmentation
https://samgeo.gishub.org/
The Segment Anything Model (SAM) for Remote Sensing Applications
Academic review of SAM for remote sensing (pre-SAM2)
https://www.sciencedirect.com/science/article/pii/S1569843223003643
SAM2 for Remote Sensing - Awesome-SAM2
Curated collection of SAM2 research and applications
https://github.com/GuoleiSun/Awesome-SAM2
Advancing Image Segmentation with SAM - ESRI
ESRI's integration of SAM into ArcGIS Pro workflows
https://www.esri.com/arcgis-blog/products/arcgis-pro/geoai/revolutionizing-image-segmentation-with-sam-segment-anything-model/