@@ -142,6 +142,7 @@ def tile( # noqa: C901
142
142
tile_z : int ,
143
143
assets : Union [Sequence [str ], str ] = (),
144
144
expression : Optional [str ] = None ,
145
+ asset_indexes : Optional [Dict [str , Indexes ]] = None , # Indexes for each asset
145
146
asset_as_band : bool = False ,
146
147
** kwargs : Any ,
147
148
) -> ImageData :
@@ -153,6 +154,7 @@ def tile( # noqa: C901
153
154
tile_z (int): Tile's zoom level index.
154
155
assets (sequence of str or str, optional): assets to fetch info from.
155
156
expression (str, optional): rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
157
+ asset_indexes (dict, optional): Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
156
158
kwargs (optional): Options to forward to the `self.reader.tile` method.
157
159
158
160
Returns:
@@ -181,16 +183,24 @@ def tile( # noqa: C901
181
183
raise MissingAssets (
182
184
"assets must be passed either via `expression` or `assets` options."
183
185
)
186
+
187
+ # indexes comes from the bidx query-parameter.
188
+ # but for asset based backend we usually use asset_bidx option.
189
+ asset_indexes = asset_indexes or {}
190
+
191
+ # We fall back to `indexes` if provided
192
+ indexes = kwargs .pop ("indexes" , None )
184
193
185
194
def _reader (asset : str , * args : Any , ** kwargs : Any ) -> ImageData :
195
+ idx = asset_indexes .get (asset ) or indexes # type: ignore
186
196
asset_info = self ._get_asset_info (asset )
187
197
reader = self ._get_reader (asset_info )
188
198
189
199
with self .ctx (** asset_info .get ("env" , {})):
190
200
with reader (
191
201
asset_info ["url" ], tms = self .tms , ** self .reader_options
192
202
) as src :
193
- data = src .tile (* args , ** kwargs )
203
+ data = src .tile (* args , indexes = idx , ** kwargs )
194
204
195
205
if asset_as_band :
196
206
if len (data .band_names ) > 1 :
0 commit comments