-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forward dataset statistics to ImageClass #531
Conversation
for prod in itertools.product(*stats): # type: ignore | ||
res.append(apply_expression(blocks, self.band_names, numpy.array(prod))) | ||
|
||
stats = list(zip([min(r) for r in zip(*res)], [max(r) for r in zip(*res)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only real interesting part of the addition (because technically you can access the metadata directly with rasterio). Here we calculate the result of the expression on the min/max values so we get the min/max of the expression output
rio_tiler/reader.py
Outdated
stat_min = float(tags.get("STATISTICS_MINIMUM")) | ||
stat_max = float(tags.get("STATISTICS_MAXIMUM")) | ||
|
||
dataset_statistics.append((stat_min, stat_max)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we only add dataset_statistics
if all the bands have it
@@ -473,7 +498,7 @@ def render( | |||
kwargs.update({"crs": self.crs}) | |||
|
|||
data = self.data.copy() | |||
datatype_range = (dtype_ranges[str(data.dtype)],) | |||
datatype_range = self.dataset_statistics or (dtype_ranges[str(data.dtype)],) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if present we use the dataset min/max for the auto rescaling!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* update rasterio requirement (#517) * update rasterio requirement * remove python 3.7 * update changelog * reader functions returns ImageData object (#515) * reader functions returns ImageData object * update changelog * remove async base reader (#520) * remove gcp reader (#521) Co-authored-by: vincentsarago <[email protected]> * avoid warning in tests * generalize buffer option (#519) * generalize buffer option * refactor buffer calculation * better tests * remove min/max zoom from baseclass attribute (#522) * remove min/max zoom from baseclass attribute * fix benchmark * split zooms methods and add tests * rename function * move apply_expression into ImageData class and use `b{ix}` for band names (#523) * move apply_expression into ImageData class and use `b{ix}` for band names * fix test * make sure we have the good number of bands * Apply expression part2 (#525) * ImageData.apply_expression return a new ImageData object * refactor Points method and deprecate asset_expression * remove unused option * Update rio_tiler/models.py * fix regex * add PointData class (#526) * add PointData class * fix test * remove deprecated * fix test 2 * better expression parsing for stac * docstring fixes * only use WarpedVRT when doing reprojection or nodata overwride (#529) * update baseclass to remove useless kwargs * update changelog * forward dataset statistics to ImageClass (#531) * forward dataset statistics to ImageClass * better type and autorescale * one more test * rename `COGReader` to `Reader` and remove relative import (#534) * rename COGReader to Reader and remove relative import * rasterio * debug * merge from branch * add note for backwards compatibility of COGReader * remove individual options attributes (#535) * remove individual options attributes * add typeDict for options * allow empty options * make sure to not change the input array * add ImageReader for non-geo images (#536) * add ImageReader for non-geo images * update changelog * Xarray reader (#530) * sketch out Xarray support * Update rio_tiler/io/xarray.py Co-authored-by: Ryan Abernathey <[email protected]> * read tile * assume crs is in the dataset * upside down * dependencies * cleanup * add more methods and cleanup * Update rio_tiler/io/xarray.py Co-authored-by: Tom Augspurger <[email protected]> * enumerate from 1 * fix * add dataset_statistics and notebook * add XarrayReader in top level import * add tests * update notebook * update changelog Co-authored-by: Ryan Abernathey <[email protected]> Co-authored-by: Tom Augspurger <[email protected]> * add migration docs * update readme * update notebooks * update docs Co-authored-by: Jeff Albrecht <[email protected]> Co-authored-by: Ryan Abernathey <[email protected]> Co-authored-by: Tom Augspurger <[email protected]>
ref #488