Skip to content

samstars Documentation

Python License Docs Repo

Multimodal individual tree crown segmentation from imagery and lidar-derived rasters.

SAM-STARS graphical abstract showing satellite imagery and lidar inputs, automatic crown prompts, canopy fusion, individual crown delineation, species classification, and annotation efficiency.

Overview

samstars is a Python package for instance segmentation of individual tree crowns from high-resolution imagery and lidar-derived rasters. The resulting crown polygons can be used for downstream species classification.

It combines:

  • high-resolution imagery (satellite, aerial, or drone)
  • lidar-derived raster layers (e.g., canopy height and density)

It automatically derives prompts from lidar structure and spectral cues to segment individual tree crowns with limited training annotations.

First Segmentation

Use the model bundle created by Training with imagery and lidar rasters prepared as described in Data Preparation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from pathlib import Path

from samstars import segment

result = segment(
    model=Path("/abs/path/model_bundle"),
    img=Path("/abs/path/image.tif"),
    chm=Path("/abs/path/chm.tif"),
    den=Path("/abs/path/first_return_density.tif"),
    out=Path("/abs/path/run_dir/segmentation_run"),
    storage="persistent",
    device="cpu",
)

print(result.crowns)

See Installation to install the library. For a minimal training and segmentation workflow, see Quick Start. For task-focused documentation, see Data Preparation, Training, Segmentation, and Downstream Analysis.