segrails.pipeline.raster

Raster generation pipeline step.

Wraps geo3d.RasterGenerator to produce a PNG raster and its GeoTransform from a point cloud file or remote EPT URL, using parameters from SegrailsConfig.

Classes

RasterStep

Generate a raster PNG from a point cloud.

Module Contents

class segrails.pipeline.raster.RasterStep(config: altametris.segrails.config.SegrailsConfig, reader: str = 'las', height_threshold: float = 4.0, raster_side: int = 35, raster_window_size: float = 2.0, color: bool = True)

Generate a raster PNG from a point cloud.

Wraps geo3d.RasterGenerator. The raster cell resolution is read from SegrailsConfig. All other generation parameters are fixed at construction time and can be overridden per-call via generate().

Parameters:
  • config – SegrailsConfig instance — provides raster_resolution, cache_dir, raster_above_ground_filter and raster_noise_outlier.

  • reader – Default point cloud reader. "las" for local files, "ept" for EPT endpoints. Overridden automatically when a dict filespec is passed.

  • height_threshold – Height threshold in metres for above-ground filtering.

  • raster_side – Side length of the output raster in metres.

  • raster_window_size – PDAL raster window size in metres.

  • color – Apply default color relief to the output PNG.

Example

>>> step = RasterStep(config, reader="las")

Local file:

>>> png_path, gt = step.generate(Path("cloud.las"), center=(448500.0, 6840200.0))

Remote EPT via U3D API:

>>> png_path, gt = step.generate(
...     {"path": "https://altametris.xyz/dev/u3d/data/proj/ept.json",
...      "headers": {"Bearer": "mytoken"}},
...     center=(448500.0, 6840200.0),
... )
_config
_reader = 'las'
_height_threshold = 4.0
_raster_side = 35
_raster_window_size = 2.0
_generator
generate(point_cloud: PointCloudSource, center: tuple[float, float], output_dir: pathlib.Path | None = None) tuple[pathlib.Path, altametris.geo3d.rasters.types.GeoTransform]

Generate a raster PNG from a point cloud.

Accepts a local file path or a remote EPT filespec dict.

Parameters:
  • point_cloud

    Point cloud source. Either:

    • str | Path — local LAS/LAZ file path.

    • dict — remote EPT filespec with keys:

      • "path" (required): EPT endpoint URL.

      • "headers" (optional): dict of HTTP headers. The "Bearer" key is forwarded as the EPT token.

  • center – Geographic center of the raster as (X, Y) in the point cloud coordinate reference system.

  • output_dir – Directory for the output PNG. Defaults to config.cache_dir / "rasters".

Returns:

Tuple of (png_path, geotransform) where png_path is the path to the generated PNG and geotransform contains georeferencing metadata for the raster.

Raises:
  • FileNotFoundError – If a local path does not exist.

  • ValueError – If the filespec dict is missing the "path" key.

  • RuntimeError – If the PDAL pipeline execution fails.