NaN pixels in LERC tiles decode as 0

Open
#354 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
data

Research direction

Start in decode_lerc in src/decoder.rs, where the mask is discarded by let (data, _mask) = lerc::decode::<T>(...). Check how the mask is represented, then apply NaN only for float type parameters so integer decoding is unchanged. Reproduce with a 64×64 float32 LERC tile containing NaN pixels in tile (0, 0); done when those pixels decode as NaN instead of 0.

Written by the indexing model from the issue text.

Description

[!NOTE]
This issue was written by Claude (Claude Code), not by @kylebarron.

Summary

NaN pixels in float LERC tiles decode as 0.

LERC stores NaN as an invalid pixel in its mask rather than as a value. decode_lerc discards the mask (let (data, _mask) = lerc::decode::<T>(...)), and invalid pixels come back as 0. libtiff fills invalid float pixels with NaN (tif_lerc.c), so GDAL returns NaN.

Evidence

Two 64×64 float32 LERC files (little endian, max_z_error=0, 32×32 tiles) written by GDAL 3.12.1, with 35 NaN pixels in tile (0, 0):

File GDAL async-tiff 0.7.0
no nodata 35 NaN 0 NaN, 35 zeros
nodata=NaN 35 NaN 0 NaN, 35 zeros
Possible fix

For float data, set the pixels the LERC mask marks as invalid to NaN, as libtiff does.

deck.gl-raster's geotiff package has the same problem; see the linked deck.gl-raster issue.

🤖 Written by Claude Code

Dominant language
Rust
Stars
125
Forks
17
Avg merge
7h 33m
Merged PRs (30d)
8

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/async-tiff

All issues in developmentseed/async-tiff

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.