diff --git a/stackstac/rio_reader.py b/stackstac/rio_reader.py index 61e44a1..ef66182 100644 --- a/stackstac/rio_reader.py +++ b/stackstac/rio_reader.py @@ -335,9 +335,10 @@ def _open(self) -> ThreadsafeRioDataset: raise RuntimeError(msg) from e if ds.count != 1: + nr_of_bands = ds.count ds.close() raise RuntimeError( - f"Assets must have exactly 1 band, but file {self.url!r} has {ds.count}. " + f"Assets must have exactly 1 band, but file {self.url!r} has {nr_of_bands}. " "We can't currently handle multi-band rasters (each band has to be " "a separate STAC asset), so you'll need to exclude this asset from your analysis." )