You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exclude transparent raster cells from statistics, stretch, and Change Detection #1810
Make raster color statistics, display stretch, and Change Detection account for cells whose alpha is 0. This behavior predates PR #1759 and is not specific to clipping. It affects RGBA rasters read from files as well as rasters produced by Project Raster or Clip.
Band statistics and Change Detection currently evaluate color values without using alpha. Transparent values can therefore affect statistics and change results. A Float32 color file can also contain values such as −3.4e38 in transparent cells; those values can affect its display stretch. This covers the Float32 stretch point in #1731, which PR #1759 leaves out.
Affected areas
Raster validity and band statistics in crates/data/src/raster/mod.rs.
Change Detection in crates/engine/src/cmd/imagery.rs, including the resampling path for its second input.
The color display-range and stretch calculation paths.
Acceptance criteria
Exclude cells with alpha 0 from color-band statistics and display-range calculations.
Exclude transparent cells from Change Detection for either input, including when the second input is resampled.
Preserve valid opaque black pixels; do not mark color value 0 as no-data solely to identify transparency.
Add regression tests for file-loaded, projected, and clipped RGBA rasters. Include opaque black cells and transparent cells with extreme Float32 color values such as −3.4e38.
Verify that existing no-data handling and valid pixel calculations remain correct.
I'd like to take this one, since it came out of #1759.
The plan:
Statistics: a colour raster with alpha (RGBA, or grey with alpha) leaves out the cells whose alpha is 0 from its colour bands' statistics. The alpha band's own statistics stay as they are, an opaque black cell still counts, and rasters without alpha don't change.
Display range: the stretch is taken from those statistics. It's also taken from the values in view (dynamic range adjustment) and from a style mask's sample, and both of those would skip see-through cells too. So a −3.4e38 in a see-through Float32 cell no longer sets the range.
Change Detection: a cell that is see-through in either input is left out. The second input's alpha is resampled onto the first's grid, the same way its band is.
Tests: RGBA rasters read from a file, projected and clipped, with opaque black cells and with −3.4e38 in see-through Float32 cells.
For reference, I checked GDAL 3.9.3 through rasterio 1.4.3. It leaves alpha-0 cells out of an 8-bit RGBA band's statistics, because it reads the alpha as the band's mask, but it doesn't do this for a 16-bit or Float32 band. RustGIS draws those cells as see-through in every pixel type, so this change leaves them out of the statistics in every type.
Activity
bearinmindcat commentedon Nov 12, 2026
I'd like to take this one, since it came out of #1759.
The plan:
For reference, I checked GDAL 3.9.3 through rasterio 1.4.3. It leaves alpha-0 cells out of an 8-bit RGBA band's statistics, because it reads the alpha as the band's mask, but it doesn't do this for a 16-bit or Float32 band. RustGIS draws those cells as see-through in every pixel type, so this change leaves them out of the statistics in every type.
docs: the see-through rule in every pixel type, not only 16-bit (open…
test(engine): Change Detection on a second raster moved by whole cell…
test(engine): the see-through rows are set through an iterator, as cl…
test(data): statistics with a validity by place are the same on any n…
fix(data, map, tiles, engine): see-through cells are left out of colo…