Skip to content

OBIA

PyPI PyPI Downloads Docker Pulls Tests Docs Contributors License

Object-based image analysis tools for geospatial rasters.

OBIA segments a raster into image objects, summarizes each object with feature columns, and uses those object-level features for classification or review. The main output is a GeoDataFrame of segment polygons that can be saved, labelled, enriched, and classified.

The library supports:

  • GeoTIFF loading with Rasterio metadata
  • SLIC and quickshift segmentation
  • spectral and texture summaries for segment objects
  • optional point-cloud height, intensity, and density features
  • point-to-segment labelling for training data
  • random forest and MLP segment classification
  • tiled large-raster workflows for supported segmentation methods

First Segmentation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from obia.handlers.geotif import open_geotiff
from obia.segmentation.segment import segment

image = open_geotiff("/path/to/image.tif")

objects = segment(
    image,
    segmentation_bands=[0, 1, 2],
    statistics_bands=[0, 1, 2, 3],
    method="slic",
    n_segments=3000,
    compactness=10,
)

objects.segments.to_file("segments.gpkg")

objects.segments is a GeoDataFrame. Each row is a segment polygon with a segment_id and calculated feature columns.

Add point-cloud features to the same rows when LiDAR or SfM points are available:

1
2
3
4
5
6
7
from obia.pointcloud import add_pointcloud_features

segments = add_pointcloud_features(
    objects.segments,
    pointcloud="/path/to/points.laz",
    metrics=["height", "intensity", "density"],
)

Next Steps

  • Installation: install OBIA with pip or set up a development environment.
  • Concepts: understand segment objects, feature sources, labels, and classification.
  • Segmentation: create object polygons and feature tables.
  • Classification: label segments and train a classifier.
  • Point Clouds: add point-cloud metrics to segment objects.
  • Large Rasters: use tiled segmentation utilities.
  • API Reference: inspect generated API documentation.