mojodna / marblecutter

Dynamic tiling of raster data for OpenAerialMap + others
Other
121 stars 25 forks source link

Incorrect min max fetching when 'rgb_bands' combination is provided in recipes #108

Open tushar10sh opened 4 years ago

tushar10sh commented 4 years ago

https://github.com/mojodna/marblecutter/blob/3d4812f2d17fe0bd809849f4ca8beb9b85efa122/marblecutter/recipes.py#L139

This part of function get band-wise min max values but use band index as key which is now re-formatted due to 3 band selection in the if 'rgb_bands' in recipes: step. Example if user has given rgb_bands=4,3,2 for Landsat 8 OLI dataset to view True color tiles, then this step just gives min/max values of bands 1, 2, 3 (all the time!!!) We can avoid this by using a regular list instead of map for recipes['rgb_bands'] and replacing the code like

min_val = source.meta.get("values", {}).get(recipes['rgb_bands'][band]-1, {}).get( "min", np.min(data[band])) max_val = source.meta.get("values", {}).get(recipes['rgb_bands'][band]-1, {}).get( "max", np.max(data[band]))

recipes['rgb_bands'] is passed down by marblecutter-virtual here https://github.com/mojodna/marblecutter-virtual/blob/6bb9b7deceae401b8d529b7cc079427a43829c0e/virtual/catalogs.py#L92 This can be changed to recipes["rgb_bands"] = [ i for i in map(int, self._rgb.split(",")) ]