File size: 9,502 Bytes
cfe4144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
pretty_name: HHDC HyperHeight LiDAR Cubes in Lance
license: cc-by-4.0
task_categories:
- image-to-image
language:
- en
tags:
- lance
- lidar
- geospatial
- remote-sensing
- neon
- canopy
- information-retrieval
size_categories:
- 10K<n<100K
configs:
- config_name: cubes
  default: true
  data_files:
  - split: train
    path: preview/train.parquet
  - split: validation
    path: preview/validation.parquet
  - split: test
    path: preview/test.parquet
---

# HHDC HyperHeight LiDAR Cubes in Lance

Find forest tiles with similar photon-return distributions, then retrieve their original LiDAR cubes for denoising and super-resolution. The HyperHeight dataset derives 3D photon-count waveforms from the National Ecological Observatory Network’s airborne discrete-return LiDAR. Each canonical cube holds 128 vertical bins across 48 × 48 footprints. [Original HHDC dataset](https://huggingface.co/datasets/anfera236/HHDC) · [HHDC-Creator pipeline](https://github.com/Anfera/HHDC-Creator)

## Data and splits

| Source split | Lance path | Cubes |
|---|---|---:|
| `train` | `data/train.lance` | 62,535 |
| `validation` | `data/validation.lance` | 13,400 |
| `test` | `data/test.lance` | 13,401 |

The native tables preserve every original `filename`, the source row order, and all 294,912 `float32` values per `cube`. Lance stores each cube as a compressed flat list of `float32` values. Reshape in NumPy C order to `[128, 48, 48]` for the original height, y, and x axes. Column metadata records the tensor shape, axis order, and dtype. The split-relative `cube_index` is its row position in the native table.

The Hugging Face Dataset Viewer uses Parquet projections of all three splits. The projections contain filenames and return statistics. `search/cubes.lance` adds a 64-dimensional vector per tile, and `source_files.lance` gives pinned URLs, original hashes, and row ranges for the source Parquet shards. [Browse the dataset](https://huggingface.co/datasets/lance-format/hhdc-lance/viewer/cubes/train) · [Release metadata](release.json)

## Search for similar cubes

The **HHDC morphology PCA-64** model encodes the actual LiDAR cube. It combines four square-root-normalized distributions covering photon returns by height, footprint occupancy by height, highest-return bins per occupied footprint, and photon density per footprint. The model pools y and x positions to compare these distributions across tiles. It standardizes the 128 input features using the original training split, projects to 64 dimensions with non-whitened PCA fitted with scikit-learn 1.9.1, and L2-normalizes the vector. The `float32` weights and encoder are versioned together as `4662fde67b87fc59fbc71455778a1bc503702b2c9faa15aa1c885688171ae7dd`. Lance uses cosine distance. The code prints `1 − distance`, with higher scores indicating closer matches. [Model parameters](model/morphology-pca64.npz) · [Model metadata](model/info.json)

The example takes a genuine held-out test cube, computes its vector, and returns five neighbors from `train`. `return_p95_bin` is the first vertical bin containing 95% of the cumulative photon count, measured from the cube’s lower edge. As a morphology sanity check across 24 evenly spaced held-out test cubes, the five nearest training neighbors had a mean absolute p95 error of 1.45 bins. A deterministic random sample of training cubes averaged 28.74 bins.

```bash
python -m pip install 'pylance==14.0.3' numpy huggingface_hub
```

```python
import lance
import numpy as np
from huggingface_hub import hf_hub_download


def morphology(cubes):
    """Return 128 morphology features and three physical summary statistics per cube."""
    array = np.asarray(cubes, dtype=np.float32).reshape(-1, 128, 48 * 48)
    count = len(array)
    profiles = array.sum(axis=2, dtype=np.float64)
    present = array > 0
    footprints = present.any(axis=1)
    top = 127 - present[:, ::-1, :].argmax(axis=1)
    density = array.sum(axis=1, dtype=np.float64)

    def distribution(matrix):
        total = matrix.sum(axis=1, keepdims=True)
        normalized = np.divide(matrix, total, out=np.zeros(matrix.shape, dtype=np.float64), where=total > 0)
        return np.sqrt(normalized)

    def histogram(values, valid):
        block = np.arange(count, dtype=np.int64)[:, None] * 16
        return np.bincount((values + block)[valid], minlength=count * 16).reshape(count, 16)

    return_profile = profiles.reshape(count, 64, 2).sum(axis=2)
    footprint_profile = present.reshape(count, 32, 4, -1).any(axis=2).sum(axis=2)
    top_histogram = histogram(top // 8, footprints)
    density_band = np.minimum(np.floor(np.log2(1 + density)).astype(np.int64), 15)
    density_histogram = histogram(density_band, np.ones_like(footprints))
    descriptor = np.concatenate([distribution(part) for part in
                                 (return_profile, footprint_profile, top_histogram, density_histogram)], axis=1)
    cumulative = profiles.cumsum(axis=1)
    total = cumulative[:, -1]
    p95_bin = (cumulative >= total[:, None] * 0.95).argmax(axis=1)
    upper_fraction = (footprints & (top >= 4)).mean(axis=1)
    mean_returns = density.mean(axis=1)
    return descriptor.astype(np.float32), np.column_stack((p95_bin, upper_fraction, mean_returns)).astype(np.float32)


def embed(descriptor, model):
    """Apply the saved training-only scaler and PCA and normalize for cosine search."""
    features = (descriptor - model['mean']) / model['scale']
    projected = (features - model['pca_mean']) @ model['components'].T
    norm = np.linalg.norm(projected, axis=-1, keepdims=True)
    return np.divide(projected, norm, out=np.zeros_like(projected), where=norm > 0).astype(np.float32)


repo = "lance-format/hhdc-lance"
root = f"hf://datasets/{repo}"
held_out = lance.dataset(root + "/data/test.lance")
sample = held_out.take([0], columns=["filename", "cube"])
cube = sample["cube"].combine_chunks().flatten().to_numpy().reshape(128, 48, 48)
print("Held-out test tile:", sample["filename"][0].as_py())
descriptor, _ = morphology(cube)
model_path = hf_hub_download(repo, "model/morphology-pca64.npz", repo_type="dataset")
with np.load(model_path, allow_pickle=False) as model:
    query = embed(descriptor, model)[0]

search = lance.dataset(root + "/search/cubes.lance")
hits = search.to_table(
    columns=["filename", "split", "cube_index", "return_p95_bin", "_distance"],
    filter="split = 'train'",
    prefilter=True,
    nearest={"column": "embedding", "q": query, "k": 5, "metric": "cosine"},
).to_pylist()
for row in hits:
    score = 1.0 - row["_distance"]
    print(f"{score:.4f}  {row['split']}/{row['filename']}  row={row['cube_index']}  p95 bin={row['return_p95_bin']}")
```

## Read original NPZ archives

The source repository also contains one legacy NPZ file per canonical cube. `legacy/cubes.lance` exposes every original archive as a Blob v2 reference. The archive retains the source dtype and its extra coordinates, bin edges, footprint counts, and metadata. Pin the external base separately so the archive bytes resolve against the audited source revision. The example reads the exact legacy archive for the search query above.

```python
import io

import lance
import numpy as np

source = "hf://datasets/anfera236/HHDC"
pin = "d0c7dc6a218f0e2c2afdfcb05afdb31b25d11263"
legacy = lance.dataset(
    "hf://datasets/lance-format/hhdc-lance/legacy/cubes.lance",
    base_store_params={source: {"hf_revision": pin}},
)
row, = legacy.to_table(
    columns=["source_path"], filter="split = 'test' AND cube_index = 0",
    with_row_id=True, limit=1,
).to_pylist()
with legacy.take_blobs("npz", ids=[row["_rowid"]])[0] as blob:
    with np.load(io.BytesIO(blob.read()), allow_pickle=False) as archive:
        original_cube = archive["cube"]
print(row["source_path"], original_cube.shape, original_cube.dtype)
```

## Source, license, and attribution

Andres Ramirez-Jaime released the HHDC dataset under CC BY 4.0. This conversion uses source commit `d0c7dc6a218f0e2c2afdfcb05afdb31b25d11263`. The changes are the lossless Lance representation, source asset references, and a morphology search with Parquet previews. The original card and the publisher’s larger replication sample are included for reference. Cite HHDC and its original NEON data product, retaining survey site and month identifiers wherever available in source provenance. [Pinned HHDC source](https://huggingface.co/datasets/anfera236/HHDC/tree/d0c7dc6a218f0e2c2afdfcb05afdb31b25d11263) · [Original dataset card](source/HHDC-README.md) · [Publisher’s replication cube](source/SampleCube/gt2.npz) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

- National Ecological Observatory Network (NEON). *Discrete return LiDAR point cloud* (DP1.30003.001). [NEON data product](https://data.neonscience.org/data-products/DP1.30003.001) · [NEON usage and citation policy](https://www.neonscience.org/usage-policies)
- Ramirez-Jaime, A., Pena-Pena, K., Arce, G. R., Harding, D., Stephen, M., and MacKinnon, J. (2024). *HyperHeight LiDAR Compressive Sampling and Machine Learning Reconstruction of Forested Landscapes*. IEEE Transactions on Geoscience and Remote Sensing. [Article](https://doi.org/10.1109/TGRS.2024.3356389)
- Ramirez-Jaime, A., Porras-Diaz, N., Arce, G. R., and Stephen, M. (2025). *Super-Resolved 3-D Satellite Lidar Imaging of Earth via Generative Diffusion Models*. IEEE Transactions on Geoscience and Remote Sensing. [Article](https://doi.org/10.1109/TGRS.2025.3543670)