Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1520b88
feat(imagery): spectral profile: chart and compare a multiband raster…
elpidiofilho Nov 8, 2026
9889e1b
fix(imagery): say every wavelength and spectral input left out (revie…
elpidiofilho Nov 8, 2026
0d6320e
fix(imagery): say a mosaic's other wavelengths and a dataset's own (r…
elpidiofilho Nov 8, 2026
4b987ce
fix(imagery): an empty wavelength is said, and lengths apart by a mil…
elpidiofilho Nov 8, 2026
0b8ba0f
fix(imagery): say wavelength units for no band (review round 4)
elpidiofilho Nov 8, 2026
14477c8
fix(imagery): say wavelength units given again, and a shadowed raster…
elpidiofilho Nov 8, 2026
6bc9547
fix(data): an empty wavelength unit names none, in both readers (revi…
elpidiofilho Nov 9, 2026
032a6a6
fix(ui): the profile's list leaves out shadowed rasters, saying so; a…
elpidiofilho Nov 9, 2026
f8f0aac
fix(imagery): a resampled raster keeps its wavelengths (review round 8)
elpidiofilho Nov 9, 2026
a6fd16b
spectral profile: say how GeoLibre's code was followed
elpidiofilho Nov 9, 2026
f59bb19
spectral profile: free colours, a namesake raster starts again, share…
elpidiofilho Nov 9, 2026
3b1779f
spectral profile: wavelengths from 1 nm to 1 m, the workspace mosaic'…
elpidiofilho Nov 9, 2026
7018460
spectral profile: say the points a raster change takes off
elpidiofilho Nov 9, 2026
f5484ae
spectral profile: one wavelength comparison, a rename followed, a map…
elpidiofilho Nov 9, 2026
d49f573
Merge main into feat/spectral-profile
elpidiofilho Nov 9, 2026
ae79f8e
Merge main into feat/spectral-profile
elpidiofilho Nov 9, 2026
fd54216
spectral profile: a flat profile labelled with its values, a case-onl…
elpidiofilho Nov 9, 2026
8c1e4f0
spectral profile: points read before an in-place edit are taken off
elpidiofilho Nov 9, 2026
e4204d5
spectral profile: a point from Identify follows a rename too
elpidiofilho Nov 9, 2026
9734f95
spectral profile: resample keeps band names, one unit in two spelling…
elpidiofilho Nov 9, 2026
4e7a4da
pam: wavelength_nm's doc comment whole again
elpidiofilho Nov 9, 2026
b31cc86
raster: an unreadable sidecar or GDAL tag says its wavelengths go too
elpidiofilho Nov 9, 2026
eb0d83a
spectral profile: Identify's button keeps Pick Points on
elpidiofilho Nov 9, 2026
0396600
docs: rewrap the wavelength paragraph's long line
elpidiofilho Nov 9, 2026
54e1189
Merge main into feat/spectral-profile
elpidiofilho Nov 9, 2026
2fffea2
Merge remote-tracking branch 'origin/main' into pr-1645
giswqs Nov 9, 2026
4045368
fix(ui): the spectral section says how many rasters couldn't be read
elpidiofilho Nov 9, 2026
ea39667
docs: one profile per point, a row per band
elpidiofilho Nov 9, 2026
29677ce
fix(engine): a tile-layer COG says its wavelengths need a window
elpidiofilho Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/analysis/src/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ impl Canvas {
.map_err(|e| e.to_string())?;
for (i, band) in out.bands.iter_mut().enumerate() {
band.name = r.bands.get(i).map_or_else(|| "Alpha".to_string(), |b| b.name.clone());
band.wavelength = r.bands.get(i).and_then(|b| b.wavelength);
if matches!(method, Method::Sample(Resampling::Nearest) | Method::Mode)
&& let Some(source) = r.bands.get(i)
{
Expand Down
13 changes: 10 additions & 3 deletions crates/data/src/raster/cog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,12 @@ fn read_layout(r: Sparse) -> Result<Parse> {
Ok(Some(v)) => match v.into_string() {
Ok(t) => super::pam::parse_gdal_metadata(&t),
Err(e) => {
lost.push(format!("its GDAL metadata isn't text ({e}): band and class names are left out"));
lost.push(format!("its GDAL metadata isn't text ({e}): band and class names and wavelengths are left out"));
None
}
},
Err(e) => {
lost.push(format!("its GDAL metadata doesn't decode ({e}): band and class names are left out"));
lost.push(format!("its GDAL metadata doesn't decode ({e}): band and class names and wavelengths are left out"));
None
}
};
Expand Down Expand Up @@ -667,6 +667,9 @@ pub struct Example {
pub sparse: bool,
/// Without overviews: the full image alone (a file saved without them).
pub no_overviews: bool,
/// Without `classes`: band `b`'s wavelength, 400 + 100 b nanometres, in GDAL's metadata
/// (its only item there).
pub wavelengths: bool,
}

impl Default for Example {
Expand All @@ -688,6 +691,7 @@ impl Default for Example {
no_table: false,
sparse: false,
no_overviews: false,
wavelengths: false,
}
}
}
Expand Down Expand Up @@ -826,6 +830,9 @@ pub fn example_with(e: &Example) -> Vec<u8> {
r#"<GDALMetadata><Item name="CLASS_3">Forest Formation</Item><Item name="CLASS_15">Pasture</Item></GDALMetadata>"#
};
t.push((42112, V::A([xml.as_bytes(), b"\0"].concat())));
} else if e.wavelengths {
let items: String = (0..nb).map(|b| format!(r#"<Item name="wavelength" sample="{b}">{}</Item>"#, 400 + 100 * b)).collect();
t.push((42112, V::A([format!("<GDALMetadata>{items}</GDALMetadata>").as_bytes(), b"\0"].concat())));
}
}
if e.int8 {
Expand Down Expand Up @@ -1073,7 +1080,7 @@ pub(crate) mod tests {
bad[entry + 8..entry + 12].copy_from_slice(&(len + 1000).to_le_bytes());
let Parse::Done(l) = layout(&Sparse::default().with_len(u64::from(len)).with(0, bad)).unwrap() else { panic!("not read") };
let said: Vec<&String> = l.lost.iter().chain(l.described.iter().flat_map(|d| d.lost.iter())).collect();
assert!(said.iter().any(|x| x.contains("band and class names are left out")), "{said:?}");
assert!(said.iter().any(|x| x.contains("band and class names and wavelengths are left out")), "{said:?}");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/data/src/raster/geotiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,9 +1240,9 @@ pub(super) fn read_limited_with_nodata(
Ok(None) => None,
Ok(Some(v)) => match v.into_string() {
Ok(t) => super::pam::parse_gdal_metadata(&t),
Err(e) => Some(super::pam::Pam::losing(format!("it isn't text ({e}): band and class names are left out"))),
Err(e) => Some(super::pam::Pam::losing(format!("it isn't text ({e}): band and class names and wavelengths are left out"))),
},
Err(e) => Some(super::pam::Pam::losing(format!("it doesn't decode ({e}): band and class names are left out"))),
Err(e) => Some(super::pam::Pam::losing(format!("it doesn't decode ({e}): band and class names and wavelengths are left out"))),
};
// Who holds the rights to the picture, kept as it reads so an export of it says so too (the
// writers make it the ASCII a tag holds, and the exports say what that changed); one that
Expand Down
25 changes: 19 additions & 6 deletions crates/data/src/raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ pub struct Band {
/// The names of the band's classes, by value, from GDAL's `.aux.xml` sidecar (see
/// [`Band::class_name`]). Empty when the band names no class.
pub classes: Vec<String>,
/// The band's central wavelength in nanometres, from GDAL's metadata (the file's tag or its
/// sidecar, [`pam::wavelength_nm`]); `None` when the file gives none.
pub wavelength: Option<f64>,
}

impl Band {
Expand Down Expand Up @@ -609,11 +612,13 @@ pub(crate) fn band_name_of(r: &Raster, band: usize) -> Option<&str> {
}

/// GDAL's metadata tag (42112) for the bands `bands` of `r`, written as samples in that order:
/// their names, and the first one's class names. Both GeoTIFF writers take it from here.
/// their names and wavelengths, and the first one's class names. Both GeoTIFF writers take it
/// from here.
pub(crate) fn gdal_metadata_of(r: &Raster, bands: &[usize]) -> Option<String> {
Comment thread
giswqs marked this conversation as resolved.
Resolved
let names: Vec<Option<&str>> = bands.iter().map(|b| band_name_of(r, *b)).collect();
let wavelengths: Vec<Option<f64>> = bands.iter().map(|b| r.bands.get(*b).and_then(|b| b.wavelength)).collect();
let first = bands.first().and_then(|b| r.bands.get(*b)).map_or(&[][..], |b| &b.classes[..]);
pam::gdal_metadata(&names, first)
pam::gdal_metadata(&names, first, &wavelengths)
}

/// Text for a TIFF ASCII tag, which holds 7-bit ASCII only: control characters (a NUL would end
Expand Down Expand Up @@ -740,6 +745,7 @@ impl Raster {
stats: if measure { BandStats::compute(&data, valid) } else { BandStats::default() },
data,
classes: Vec::new(),
wavelength: None,
Comment thread
elpidioassinaturas marked this conversation as resolved.
Resolved
})
.collect();
let mut r = Raster {
Expand Down Expand Up @@ -776,14 +782,18 @@ impl Raster {
/// metadata", "its .aux.xml sidecar").
pub fn apply_pam(&mut self, pam: &pam::Pam, from: &str) {
self.lost.extend(pam.lost.iter().map(|l| format!("{from}: {l}")));
// Names for bands the raster doesn't have have nowhere to go.
// Names and wavelengths for bands the raster doesn't have have nowhere to go.
let beyond = pam
.bands
.iter()
.filter(|b| (b.band == 0 || b.band > self.bands.len()) && (b.description.is_some() || !b.categories.is_empty()))
.filter(|b| {
(b.band == 0 || b.band > self.bands.len())
&& (b.description.is_some() || !b.categories.is_empty() || b.wavelength.is_some())
})
.count();
if beyond > 0 {
self.lost.push(format!("{from}: names for {beyond} band(s) it doesn't have (it has {}) left out", self.bands.len()));
self.lost
.push(format!("{from}: names or wavelengths for {beyond} band(s) it doesn't have (it has {}) left out", self.bands.len()));
Comment thread
elpidioassinaturas marked this conversation as resolved.
Resolved
}
// So is a no-data value: it isn't the raster's.
let outside = pam.bands.iter().filter(|b| (b.band == 0 || b.band > self.bands.len()) && b.nodata.is_some()).count();
Expand Down Expand Up @@ -836,6 +846,9 @@ impl Raster {
if let Some(p) = p.filter(|p| !p.categories.is_empty()) {
band.classes = p.categories.clone();
}
if let Some(w) = p.and_then(|p| p.wavelength) {
Comment thread
giswqs marked this conversation as resolved.
Resolved
band.wavelength = Some(w);
}
Comment thread
giswqs marked this conversation as resolved.
Resolved
let stored = p.and_then(|p| p.stats).filter(|_| overview);
if recompute || stored.is_some() {
band.stats = BandStats::compute_with(&band.data, valid, stored);
Expand Down Expand Up @@ -1621,7 +1634,7 @@ pub(crate) mod tests {
pam::SIDECAR,
);
assert!(
one.lost.iter().any(|l| l == "its .aux.xml sidecar: names for 1 band(s) it doesn't have (it has 1) left out"),
one.lost.iter().any(|l| l == "its .aux.xml sidecar: names or wavelengths for 1 band(s) it doesn't have (it has 1) left out"),
"{:?}",
one.lost
);
Expand Down
Loading
Loading