spaceborne_lidar¶
Read ICESat-2 and GEDI spaceborne LiDAR footprints from HDF5 granules.
This is the Python counterpart of the app's ICESat-2 / GEDI reader
(packages/plugins/src/plugins/spaceborne-lidar.ts) and follows the same
rules, so a layer built here looks like one added through Add Data in the app:
- ICESat-2 ATL06 (land ice height) and ATL08 (land and vegetation height),
one footprint per along-track segment in each ground track
gt1l..gt3r. - GEDI L2A (elevation and relative heights), L2B (canopy cover and vertical
profile) and L4A (aboveground biomass density), one footprint per shot in
each beam
BEAM0000..BEAM1011.
Each footprint becomes a GeoJSON point with the chosen fields plus beam,
beam_type (strong/weak or power/coverage), time (UTC) and
distance_km (along-track distance from the first footprint of its beam).
Reading needs h5py and NumPy: pip install "geolibre[spaceborne]".
FieldSpec
dataclass
¶
FieldSpec(path: str, name: str | None = None, column: int | None = None, scale: float | None = None)
A dataset to read for every footprint, relative to the beam group.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
Dataset path, e.g. |
name |
str | None
|
Property name; defaults to the path's last segment. |
column |
int | None
|
Column of a 2-D dataset (GEDI |
scale |
float | None
|
Multiplier applied to the stored value (GEDI L2B |
ProductSpec
dataclass
¶
ProductSpec(id: str, label: str, mission: str, beam_pattern: Pattern[str], lat: str, lon: str, time: str, defaults: tuple[FieldSpec, ...], primary_field: str, quality_paths: tuple[str, ...] = (), quality_keep: Any = None, footprint: str = 'segment', extra: dict[str, Any] = dict())
How to read one product: datasets, defaults and the quality rule.
SpaceborneLidarResult
dataclass
¶
SpaceborneLidarResult(product: str, geojson: dict[str, Any], total: int, matched: int, kept: int, stride: int, per_beam: dict[str, int])
Footprints read from a granule, with counts for reporting.
Attributes:
| Name | Type | Description |
|---|---|---|
product |
str
|
The product id. |
geojson |
dict[str, Any]
|
A FeatureCollection of points. |
total |
int
|
Footprints in the chosen beams. |
matched |
int
|
Footprints that passed the quality and extent filters. |
kept |
int
|
Footprints in |
stride |
int
|
The thinning step (1 when nothing was dropped). |
per_beam |
dict[str, int]
|
|
detect_product
¶
detect_product(short_name: str | None, file_name: str | None = None) -> str | None
Identify a product from a short_name attribute or a file name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short_name
|
str | None
|
The granule's |
required |
file_name
|
str | None
|
The file name, used when the attribute is missing. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
The product id ( |
str | None
|
|
read_spaceborne_lidar
¶
read_spaceborne_lidar(source: str | PathLike[str], *, product: str | None = None, beams: Sequence[str] | None = None, fields: Iterable[Any] | None = None, quality_filter: bool = True, bbox: Sequence[float] | None = None, max_points: int | None = DEFAULT_MAX_POINTS, missions: Sequence[str] | None = None) -> SpaceborneLidarResult
Read an ICESat-2 or GEDI granule's footprints as GeoJSON points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | PathLike[str]
|
Path to the HDF5 granule. |
required |
product
|
str | None
|
Product id; detected from the granule when omitted. |
None
|
beams
|
Sequence[str] | None
|
Beam or ground-track groups to read (all by default). |
None
|
fields
|
Iterable[Any] | None
|
Fields to attach: default-field names ( |
None
|
quality_filter
|
bool
|
Drop footprints the product's quality flag rejects. |
True
|
bbox
|
Sequence[float] | None
|
|
None
|
max_points
|
int | None
|
Cap on footprints; each beam is thinned evenly to stay
under it. |
DEFAULT_MAX_POINTS
|
missions
|
Sequence[str] | None
|
Accepted missions ( |
None
|
Returns:
| Type | Description |
|---|---|
SpaceborneLidarResult
|
The footprints and counts. |
Raises:
| Type | Description |
|---|---|
ImportError
|
Without h5py / NumPy. |
ValueError
|
For an unsupported product or a granule with no footprints. |
spaceborne_lidar_layer
¶
spaceborne_lidar_layer(source: str | PathLike[str], name: str | None = None, *, missions: Sequence[str] | None = None, product: str | None = None, beams: Sequence[str] | None = None, fields: Iterable[Any] | None = None, quality_filter: bool = True, bbox: Sequence[float] | None = None, max_points: int | None = DEFAULT_MAX_POINTS, color_by: str | None = None, colormap: str = 'viridis', class_count: int = 7, scheme: str = 'quantile', **style: Any) -> tuple[dict[str, Any], SpaceborneLidarResult]
Build a GeoJSON point layer from an ICESat-2 or GEDI granule.
The layer matches one added through the app's Add Data → ICESat-2 / GEDI:
small points, graduated colors on the product's main field (or
color_by), and metadata.sourceKind == "spaceborne-lidar".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | PathLike[str]
|
Path to the HDF5 granule. |
required |
name
|
str | None
|
Layer name; |
None
|
missions
|
Sequence[str] | None
|
Accepted missions ( |
None
|
product
|
str | None
|
Product id; detected from the granule when omitted. See
|
None
|
beams
|
Sequence[str] | None
|
Beams to read; see |
None
|
fields
|
Iterable[Any] | None
|
Fields to read; see |
None
|
quality_filter
|
bool
|
Drop low-quality footprints; see
|
True
|
bbox
|
Sequence[float] | None
|
Bounding box filter; see |
None
|
max_points
|
int | None
|
Point cap; see |
DEFAULT_MAX_POINTS
|
color_by
|
str | None
|
Field to color by; the product's main field by default. Pass
|
None
|
colormap
|
str
|
Color ramp for the graduated colors. |
'viridis'
|
class_count
|
int
|
Number of color classes. |
7
|
scheme
|
str
|
|
'quantile'
|
**style
|
Any
|
Style overrides (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], SpaceborneLidarResult]
|
The layer dict and the read result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a granule of another mission, or no footprints kept. |