@@ -130,7 +130,7 @@ def maxzoom(self):
130130 return self ._maxzoom
131131
132132 @property
133- def band_names (self ) -> List [str ]:
133+ def band_descriptions (self ) -> List [str ]:
134134 """
135135 Return list of `band descriptions` in DataArray.
136136
@@ -152,7 +152,7 @@ def band_names(self) -> List[str]:
152152 if coords_name :
153153 return [str (self .input .coords [coords_name [0 ]].data )]
154154
155- return [self .input .name or "array " ]
155+ return [self .input .name or "" ]
156156
157157 return [str (band ) for d in self ._dims for band in self .input [d ].values ]
158158
@@ -165,7 +165,7 @@ def info(self) -> Info:
165165 "crs" : CRS_to_uri (self .crs ) or self .crs .to_wkt (),
166166 "band_metadata" : [(f"b{ ix } " , v ) for ix , v in enumerate (metadata , 1 )],
167167 "band_descriptions" : [
168- (f"b{ ix } " , v ) for ix , v in enumerate (self .band_names , 1 )
168+ (f"b{ ix } " , v ) for ix , v in enumerate (self .band_descriptions , 1 )
169169 ],
170170 "dtype" : str (self .input .dtype ),
171171 "nodata_type" : "Nodata" if self .input .rio .nodata is not None else "None" ,
@@ -184,10 +184,12 @@ def info(self) -> Info:
184184
185185 def _sel_indexes (
186186 self , indexes : Optional [Indexes ] = None
187- ) -> Tuple [xarray .DataArray , List [str ]]:
187+ ) -> Tuple [xarray .DataArray , List [str ], List [ str ] ]:
188188 """Select `band` indexes in DataArray."""
189189 da = self .input
190- band_names = self .band_names
190+ band_descriptions = self .band_descriptions
191+ band_names = [f"b{ ix + 1 } " for ix in range (self .input .rio .count )]
192+
191193 if indexes := cast_to_sequence (indexes ):
192194 assert all (v > 0 for v in indexes ), "Indexes value must be >= 1"
193195 if da .ndim == 2 :
@@ -196,13 +198,15 @@ def _sel_indexes(
196198 f"Invalid indexes { indexes } for array of shape { da .shape } "
197199 )
198200
199- return da , band_names
201+ return da , band_names , band_descriptions
200202
201203 indexes = [idx - 1 for idx in indexes ]
204+
202205 da = da [indexes ]
203- band_names = [self .band_names [idx ] for idx in indexes ]
206+ band_descriptions = [band_descriptions [idx ] for idx in indexes ]
207+ band_names = [band_names [idx ] for idx in indexes ]
204208
205- return da , band_names
209+ return da , band_names , band_descriptions
206210
207211 def statistics (
208212 self ,
@@ -217,7 +221,7 @@ def statistics(
217221 """Return statistics from a dataset."""
218222 hist_options = hist_options or {}
219223
220- da , band_names = self ._sel_indexes (indexes )
224+ da , band_names , _ = self ._sel_indexes (indexes )
221225
222226 if nodata is not None :
223227 da = da .rio .write_nodata (nodata )
@@ -268,7 +272,7 @@ def tile(
268272 f"Tile(x={ tile_x } , y={ tile_y } , z={ tile_z } ) is outside bounds"
269273 )
270274
271- da , band_names = self ._sel_indexes (indexes )
275+ da , band_names , band_descriptions = self ._sel_indexes (indexes )
272276
273277 if nodata is not None :
274278 da = da .rio .write_nodata (nodata )
@@ -312,6 +316,7 @@ def tile(
312316 crs = dst_crs ,
313317 dataset_statistics = stats ,
314318 band_names = band_names ,
319+ band_descriptions = band_descriptions ,
315320 nodata = da .rio .nodata ,
316321 )
317322
@@ -357,7 +362,7 @@ def part(
357362
358363 dst_crs = dst_crs or bounds_crs
359364
360- da , band_names = self ._sel_indexes (indexes )
365+ da , band_names , band_descriptions = self ._sel_indexes (indexes )
361366
362367 if nodata is not None :
363368 da = da .rio .write_nodata (nodata )
@@ -406,6 +411,7 @@ def part(
406411 crs = da .rio .crs ,
407412 dataset_statistics = stats ,
408413 band_names = band_names ,
414+ band_descriptions = band_descriptions ,
409415 nodata = da .rio .nodata ,
410416 )
411417
@@ -457,7 +463,7 @@ def preview(
457463 UserWarning ,
458464 )
459465
460- da , band_names = self ._sel_indexes (indexes )
466+ da , band_names , band_descriptions = self ._sel_indexes (indexes )
461467
462468 if nodata is not None :
463469 da = da .rio .write_nodata (nodata )
@@ -500,6 +506,7 @@ def preview(
500506 crs = da .rio .crs ,
501507 dataset_statistics = stats ,
502508 band_names = band_names ,
509+ band_descriptions = band_descriptions ,
503510 nodata = da .rio .nodata ,
504511 )
505512
@@ -547,7 +554,7 @@ def point(
547554 ):
548555 raise PointOutsideBounds ("Point is outside dataset bounds" )
549556
550- da , band_names = self ._sel_indexes (indexes )
557+ da , band_names , band_descriptions = self ._sel_indexes (indexes )
551558
552559 if nodata is not None :
553560 da = da .rio .write_nodata (nodata )
@@ -568,6 +575,7 @@ def point(
568575 coordinates = (lon , lat ),
569576 crs = coord_crs ,
570577 band_names = band_names ,
578+ band_descriptions = band_descriptions ,
571579 pixel_location = (x , y ),
572580 nodata = da .rio .nodata ,
573581 )
0 commit comments