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 1
1
2
2
# Unreleased
3
3
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
+
4
55
* only cast data to ` uint8 ` if colormap values are of type ` uint8 `
5
56
* add ` alpha_mask ` attribute to ` ImageData ` class
6
57
* allow partial alpha values from alpha band
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ def read(
314
314
data ,
315
315
bounds = out_bounds ,
316
316
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 ],
318
318
dataset_statistics = dataset_statistics ,
319
319
metadata = dataset .tags (),
320
320
)
Original file line number Diff line number Diff line change @@ -414,6 +414,13 @@ def test_statistics():
414
414
assert stats ["b1*2" ]
415
415
assert stats ["b1" ].min == stats ["b1*2" ].min / 2
416
416
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
+
417
424
418
425
def test_Reader_Options ():
419
426
"""Set options in reader."""
@@ -1010,10 +1017,10 @@ def test_metadata_img():
1010
1017
img = src .preview ()
1011
1018
assert img .dataset_statistics
1012
1019
assert img .metadata
1013
- assert img .band_names == ["b1 " ]
1020
+ assert img .band_names == ["Green " ]
1014
1021
1015
1022
stats = src .statistics ()
1016
- assert "b1 " in stats
1023
+ assert "Green " in stats
1017
1024
1018
1025
1019
1026
def test_feature_statistics ():
You can’t perform that action at this time.
0 commit comments