alsdb.processing.trees.segment_trees#

alsdb.processing.trees.segment_trees(provider: TileDBProvider, bbox: tuple[float, float, float, float] | None = None, year: int | None = None, min_points: int = 10, min_height: float = 3.0, radius: float = 2.0, adaptive_radius: bool = False, voxel_size: float | None = None, tile_size: float | None = None, tile_buffer: float = 30.0, n_workers: int = 1, crown_fraction: float = 0.5) tuple[ndarray, DataFrame][source]#

Segment individual trees using filters.litree.

Parameters:
  • provider – TileDB provider instance.

  • bbox – Spatial filter (min_x, min_y, max_x, max_y). Uses the full array domain when None.

  • year – Optional survey year filter.

  • min_points – Minimum ALS points for a cluster to be labelled as a tree.

  • min_height – Minimum tree height in metres.

  • radiusfilters.litree search radius (m). Used when adaptive_radius is False. Increase for sparser clouds or wider-crowned trees.

  • adaptive_radius – If True, compute the search radius per tile from P75 HAG using wf(h) = 0.07 * h + 0.6 (Murphy et al. lidar-forestry approach). Overrides radius.

  • voxel_size – Poisson disk sampling radius (m) applied before filters.litree to speed up the graph build. 0.5 m is a good starting point for dense ALS (> 5 pts/m²). None disables downsampling.

  • tile_size – Sub-tile side length (m). When provided the area is partitioned into tiles and processed in parallel (recommended for areas > 0.5 km²). None processes the full bbox in one pass.

  • tile_buffer – Overlap buffer (m) added to each tile query so trees at edges are fully captured. Default 30 m.

  • n_workers – Thread pool size. Effective only when tile_size is set.

  • crown_fraction – Fraction of tree height used as the lower bound for crown-area computation (default 0.5 = upper half of each tree). Only points at or above crown_fraction × height contribute to the convex hull used for crown_area and crown_radius. Reducing this value includes more understory returns and will increase the area estimate; increasing it focuses on the uppermost crown.

Returns:

  • points (np.ndarray) – Structured array with HeightAboveGround and TreeID fields. TreeID = 0 means unassigned. Points from all tiles are concatenated; TreeIDs are re-numbered 1 … N globally.

  • trees (pd.DataFrame) – One row per tree, sorted by descending height. Empty if none found.