lerc-rust
Pure-Rust LERC decoding for raster and elevation data. No C/C++ FFI, no build
scripts, and a decoder-first API designed to be reused by container crates such
as geotiff-rust.
Crates
| Crate | Description |
|---|---|
lerc-core |
Codec-neutral shared types, errors, typed raster views, and sample helpers |
lerc-reader |
Pure-Rust LERC inspection and decode paths for Lerc1 and Lerc2 blobs |
lerc-writer |
Pure-Rust Lerc2 single-blob writer with mask, depth, checksum, and tiled emit paths |
Usage
use ;
let blob = read?;
let info = get_blob_info?;
println!;
let raster: ArrayD = decode_ndarray?;
let mask = decode_mask_ndarray?;
println!;
use RasterView;
use ;
let pixels = vec!;
let blob = encode?;
Single-blob entry points are strict. If you intentionally want first-blob
inspection or decode from a concatenated payload, use inspect_first() or
decode_first().
Concatenated band sets decode to bands-last arrays by default, and can also be requested in BSQ order:
let rgb: ArrayD = decode_band_set_ndarray?;
assert_eq!;
let : =
decode_band_set_vec?;
assert_eq!;
Supported Now
- Lerc1 header parsing, mask decoding, tiled block decode, and concatenated shared-mask band sets
- Lerc2 header parsing, Fletcher32 verification, mask decoding, constant/raw, tiled, bit-stuffed, and Huffman decode paths
- Lerc2 single-blob writes with optional masks, depth metadata, checksum, and constant/raw/bit-stuffed tiles
- Native typed decode and type-promoting
f64decode - Strict single-blob APIs plus permissive first-blob adapters for concatenated payloads
- Direct
ndarray::ArrayDconversion for rasters, band sets, and masks, with selectable band layout - Codec-neutral typed raster views and shared metadata types in
lerc-core
Testing
Interop fixtures are vendored in the repository under
testdata/interoperability.
The default test suite covers:
- synthetic decoder-path unit tests embedded in
lerc-reader - official Esri fixtures for Lerc1, masked Lerc2, and concatenated multi-band Lerc2
- an Esri JavaScript sanity fixture for
depth > 1 - malformed-input regression coverage for strict parsing, mask RLE, Huffman tables, bit-stuffed payloads, concatenated parsing, and writer roundtrips/output sizing
Reference-library parity tests compare both decode and writer output against
Esri's official libLerc decoder when a compiled helper path is configured;
otherwise they self-skip:
LERC_READER_REFERENCE_HELPER="" \
LERC_READER_REFERENCE_HELPER="" \
For a reproducible reference environment, run the Docker harness:
Criterion benchmark entry points live in lerc-reader for decode-vs-libLerc
comparison and in lerc-writer for encode / encode+decode throughput:
For methodology and current benchmark notes, see the repository copy of docs/benchmark-report.md.
cargo-fuzz targets for decoder hardening live under fuzz/:
License
MIT OR Apache-2.0