* added `ImageData` output class for all `rio_tiler.io` classes returning numpy array-like types (`tile, mask = method()`)
python
from rio_tiler.io import COGReader
from rio_tiler.models import ImageData
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
r = cog.preview()
assert isinstance(r, ImageData)
data, mask = r
assert data.shape == (3, 892, 1024)
**Note**: the class keeps the compatibility with previous notation: `tile, mask = ImageData`
* add pydantic models for IO outputs (Metadata, Info, ...)
* change output form for `band_metadata`, `band_descriptions` and do not add band description when not found.
python
Before
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
i = cog.info()
print(i["band_metadata"])
print(i["band_descriptions"])
[(1, {}), (2, {}), (2, {})]
[(1, 'band1'), (2, 'band2'), (2, 'band3')]
Now
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
i = cog.info()
print(i.band_metadata)
print(i.band_descriptions)
[('1', {}), ('2', {}), ('3', {})]
[('1', ''), ('2', ''), ('3', '')]
* change output form for `stats`
python
Before
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
print(cog.stats())
{
1: {...},
2: {...},
3: {...}
}
Now
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
print(cog.stats())
{
"1": {...},
"2": {...},
"3": {...}
}
* updated `rio_tiler.utils._stats` function to replace `pc` by `percentiles`
python
with COGReader("/Users/vincentsarago/S-2_20200422_COG.tif") as cog:
print(cog.stats()["1"].json())
{"percentiles": [19.0, 168.0], "min": 0.0, "max": 255.0, ...}
* make `rio_tiler.colormap.ColorMap` object immutable. Registering a new colormap will new returns a now instance of ColorMap(https://github.com/cogeotiff/rio-tiler/issues/289).
* changed the `rio_tiler.colormap.ColorMap.register()` method to take a dictionary as input (instead of name + dict).
python
from rio_tiler.colormap import cmap default cmap
previous
cmap.register("acmap", {0: [0, 0, 0, 0], ...})
Now
cmap = cmap.register({"acmap": {0: [0, 0, 0, 0], ...}})
* added the possibility to automatically register colormaps stored as `.npy` file in a directory, if `COLORMAP_DIRECTORY` environment variable is set with the name of the directory.
* Update to morecantile 2.0.0