File tree Expand file tree Collapse file tree 3 files changed +61
-3
lines changed
Expand file tree Collapse file tree 3 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 11
22# Unreleased
33
4+ # 8.0.0
5+
6+ * use ** description** as band name (instead of ` b{ix} ` ) in ` Reader ` 's outputs ** breaking change**
7+
8+ ``` python
9+ # before
10+ with Reader(" tests/fixtures/cog_tags.tif" ) as src:
11+ info = src.info()
12+ img = src.preview()
13+ stats = src.statistics()
14+
15+ print (info.band_descriptions)
16+ >> [(' b1' , ' Green' )]
17+
18+ print (img.band_names)
19+ >> [' b1' ]
20+
21+ print (list (stats))
22+ >> [' b1' ]
23+
24+ # now
25+ with Reader(" tests/fixtures/cog_tags.tif" ) as src:
26+ info = src.info()
27+ img = src.preview()
28+ stats = src.statistics()
29+
30+ print (info.band_descriptions)
31+ >> [(' b1' , ' Green' )]
32+
33+ print (img.band_names)
34+ >> [' Green' ]
35+
36+ print (list (stats))
37+ >> [' Green' ]
38+
39+ # Band without description
40+ with Reader(" tests/fixtures/cog.tif" ) as src:
41+ info = src.info()
42+ stats = src.statistics()
43+ img = src.preview()
44+
45+ print (info.band_descriptions)
46+ >> [(' b1' , ' ' )]
47+
48+ print (list (stats))
49+ >> [' b1' ]
50+
51+ print (list (stats))
52+ >> [' b1' ]
53+ ```
54+
455* only cast data to ` uint8 ` if colormap values are of type ` uint8 `
556* add ` alpha_mask ` attribute to ` ImageData ` class
657* allow partial alpha values from alpha band
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ def read(
314314 data ,
315315 bounds = out_bounds ,
316316 crs = dataset .crs ,
317- band_names = [f"b{ idx } " for idx in indexes ],
317+ band_names = [dataset . descriptions [ ix - 1 ] or f"b{ idx } " for idx in indexes ],
318318 dataset_statistics = dataset_statistics ,
319319 metadata = dataset .tags (),
320320 )
Original file line number Diff line number Diff line change @@ -414,6 +414,13 @@ def test_statistics():
414414 assert stats ["b1*2" ]
415415 assert stats ["b1" ].min == stats ["b1*2" ].min / 2
416416
417+ with Reader (COG_TAGS ) as src :
418+ stats = src .statistics ()
419+ assert len (stats ) == 1
420+ assert isinstance (stats ["Green" ], BandStatistics )
421+ assert stats ["Green" ].percentile_2
422+ assert stats ["Green" ].percentile_98
423+
417424
418425def test_Reader_Options ():
419426 """Set options in reader."""
@@ -1010,10 +1017,10 @@ def test_metadata_img():
10101017 img = src .preview ()
10111018 assert img .dataset_statistics
10121019 assert img .metadata
1013- assert img .band_names == ["b1 " ]
1020+ assert img .band_names == ["Green " ]
10141021
10151022 stats = src .statistics ()
1016- assert "b1 " in stats
1023+ assert "Green " in stats
10171024
10181025
10191026def test_feature_statistics ():
You can’t perform that action at this time.
0 commit comments