satellit_sam.core.heightmap

Auto-generated from satellit_sam/src/satellit_sam/core/heightmap.py by satellit_sam/scripts/generate_api_docs.py.

Heightmap generation from LiDAR point cloud data.

This module provides functionality to read LiDAR .las files and generate
grayscale height maps that can be used for visualization and further processing.

Back to API index

Functions

create_heightmap_from_las

def create_heightmap_from_las(
    las_path: str | Path,
    resolution: float | None = None,
    method: Literal["max", "mean", "median"] = "max",
    width: int | None = None,
    height: int | None = None,
) -> HeightMap:
Create a height map from a LiDAR .las file.

This is a convenience function that combines loading LiDAR data and
creating a height map in one step.

Arguments

  • las_path: Path to .las file resolution: Grid cell size in meters. If None, calculated from width/height or defaults to 0.5. Cannot be used together with width/height parameters. method: Method to aggregate heights in each cell ('max', 'mean', 'median') width: Target width in pixels. If provided with height, resolution is calculated. Cannot be used together with resolution parameter. height: Target height in pixels. If provided with width, resolution is calculated. Cannot be used together with resolution parameter.

Returns

  • HeightMap object
  • Examples: >>> # Using resolution >>> heightmap = create_heightmap_from_las("data.las", resolution=1.0) >>> heightmap.save("heightmap.png")
  • >>> # Using fixed dimensions >>> heightmap = create_heightmap_from_las("data.las", width=1024, height=1024) >>> heightmap.save("heightmap.png")

Classes

LiDARData

Container for LiDAR point cloud data.

Attributes

No public class attributes detected.

Methods

num_points
def num_points(self) -> int:

Get total number of points.

x_range
def x_range(self) -> tuple[float, float]:

Get min and max X coordinates.

y_range
def y_range(self) -> tuple[float, float]:

Get min and max Y coordinates.

z_range
def z_range(self) -> tuple[float, float]:

Get min and max Z coordinates.

from_las
def from_las(las_path: str | Path) -> "LiDARData":
Read LiDAR data from .las file.

Arguments

  • las_path: Path to .las file

Returns

  • LiDARData object containing point cloud coordinates

Exceptions

  • FileNotFoundError: If the .las file doesn't exist

HeightMap

2D height map representation.

Attributes

No public class attributes detected.

Methods

shape
def shape(self) -> tuple[int, int]:

Get height map dimensions (height, width).

z_range
def z_range(self) -> tuple[float, float]:

Get min and max height values.

to_grayscale
def to_grayscale(
    self, z_min: float | None = None, z_max: float | None = None
) -> np.ndarray:
Convert height map to grayscale image (0-255).

Arguments

  • z_min: Minimum height value for normalization. If None, uses data minimum. z_max: Maximum height value for normalization. If None, uses data maximum.

Returns

  • 2D numpy array with uint8 values (0-255)
to_rgb
def to_rgb(self, z_min: float | None = None, z_max: float | None = None) -> np.ndarray:
Convert height map to RGB image (grayscale).

Arguments

  • z_min: Minimum height value for normalization. If None, uses data minimum. z_max: Maximum height value for normalization. If None, uses data maximum.

Returns

  • 3D numpy array with uint8 values (height, width, 3)
to_image
def to_image(self, z_min: float | None = None, z_max: float | None = None) -> Image:
Convert height map to Image object.

Arguments

  • z_min: Minimum height value for normalization. If None, uses data minimum. z_max: Maximum height value for normalization. If None, uses data maximum.

Returns

  • Image object with grayscale height map (flipped vertically so north is up)
save
def save(
    self, path: str | Path, z_min: float | None = None, z_max: float | None = None
) -> None:
Save height map as grayscale image file.

Arguments

  • path: Output file path z_min: Minimum height value for normalization. If None, uses data minimum. z_max: Maximum height value for normalization. If None, uses data maximum.
from_lidar
def from_lidar(
    lidar: LiDARData,
    resolution: float | None = None,
    method: Literal["max", "mean", "median"] = "max",
    width: int | None = None,
    height: int | None = None,
) -> "HeightMap":
Create height map from LiDAR point cloud data.

Arguments

  • lidar: LiDARData object containing point cloud resolution: Grid cell size in meters. If None, calculated from width/height. Cannot be used together with width/height parameters. method: Method to aggregate heights in each cell: - 'max': Use maximum height (good for canopy height) - 'mean': Use average height - 'median': Use median height width: Target width in pixels. If provided with height, resolution is calculated. Cannot be used together with resolution parameter. height: Target height in pixels. If provided with width, resolution is calculated. Cannot be used together with resolution parameter.

Returns

  • HeightMap object

Exceptions

  • ValueError: If neither resolution nor width/height are provided, or if both are provided