Skip to content
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

[Not ready] add warning when mixing nodata/mask/alpha #402

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,9 +31,8 @@ jobs:
- name: Run Tox
run: tox -e py

# Run pre-commit (only for python-3.8)
# Run pre-commit
- name: run pre-commit
if: matrix.python-version == 3.8
run: pre-commit run --all-files

- name: Upload Results
Expand Down
143 changes: 143 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,146 @@
# 3.0.0 (TDB)

* add `crs` property in `rio_tiler.io.base.SpatialMixin` (https://github.com/cogeotiff/rio-tiler/pull/429)
* add `geographic_bounds` in `rio_tiler.io.base.SpatialMixin` to return bounds in WGS84 (https://github.com/cogeotiff/rio-tiler/pull/429)

```python
from rio_tiler.io import COGReader

with COGReader("https://rio-tiler-dev.s3.amazonaws.com/data/fixtures/cog.tif") as cog:
print(cog.bounds)
>> (373185.0, 8019284.949381611, 639014.9492102272, 8286015.0)

print(cog.crs)
>> "EPSG:32621"

print(cog.geographic_bounds)
>> (-61.28762442711404, 72.22979795551834, -52.301598718454485, 74.66298001264106)
```

* Allow errors to be ignored when trying to find `zooms` for dataset in `rio_tiler.io.COGReader`. If we're not able to find the zooms in selected TMS, COGReader will defaults to the min/max zooms of the TMS (https://github.com/cogeotiff/rio-tiler/pull/429)

```python
from pyproj import CRS
from morecantile import TileMatrixSet

from rio_tiler.io import COGReader

# For a non-earth dataset there is no available transformation from its own CRS and the default WebMercator TMS CRS.
with COGReader("https://rio-tiler-dev.s3.amazonaws.com/data/fixtures/cog_nonearth.tif") as cog:
>> UserWarning: Cannot dertermine min/max zoom based on dataset informations, will default to TMS min/max zoom.

print(cog.minzoom)
>> 0

print(cog.maxzoom)
>> 24

# if we use a `compatible TMS` then we don't get warnings
europa_crs = CRS.from_authority("ESRI", 104915)
europa_tms = TileMatrixSet.custom(
crs=europa_crs,
extent=europa_crs.area_of_use.bounds,
matrix_scale=[2, 1],
)
with COGReader(
"https://rio-tiler-dev.s3.amazonaws.com/data/fixtures/cog_nonearth.tif",
tms=europa_tms,
) as cog:
print(cog.minzoom)
>> 4

print(cog.maxzoom)
>> 6
```

* compare dataset bounds and tile bounds in TMS crs in `rio_tiler.io.base.SpatialMixin.tile_exists` method to allow dataset and TMS not compatible with WGS84 crs (https://github.com/cogeotiff/rio-tiler/pull/429)
* use `httpx` package instead of requests (author @rodrigoalmeida94, https://github.com/cogeotiff/rio-tiler/pull/431)
* warn user when dataset has Nodata value in addition to a Mask or an Alpha band (https://github.com/cogeotiff/rio-tiler/pull/402)

**breaking changes**

* update morecantile requirement to version >=3.0 (https://github.com/cogeotiff/rio-tiler/pull/418)
* remove python 3.6 support (https://github.com/cogeotiff/rio-tiler/pull/418)
* remove `max_size` defaults for `COGReader.part` and `COGReader.feature`, which will now default to full resolution reading.

```python
# before
with COGReader("my.tif") as cog:
img = cog.part(*cog.dataset.bounds, dst_crs=cog.dataset.crs, bounds_crs=cog.dataset.crs)
# by default image should be max 1024x1024
assert max(img.width, 1024) # by default image should be max 1024x1024
assert max(img.height, 1024)

# now (there is no more max_size default)
with COGReader("my.tif") as cog:
img = cog.part(*cog.dataset.bounds, dst_crs=cog.dataset.crs, bounds_crs=cog.dataset.crs)
assert img.width == cog.dataset.width
assert img.height == cog.dataset.height
```

* deprecate `.metadata` and `.stats` methods (https://github.com/cogeotiff/rio-tiler/pull/425)
* add `.statistics` method in base classes (https://github.com/cogeotiff/rio-tiler/pull/427)

* remove `rio_tiler.io.base.SpatialMixin.spatial_info` and `rio_tiler.io.base.SpatialMixin.center` properties (https://github.com/cogeotiff/rio-tiler/pull/429)

* Reader's `.bounds` property should now be in dataset's CRS, not in `WGS84` (https://github.com/cogeotiff/rio-tiler/pull/429)

```python
# before
with COGReader("my.tif") as cog:
print(cog.bounds)
>>> (-61.287001876638215, 15.537756794450583, -61.27877967704677, 15.542486503997608)

# now
with COGReader("my.tif") as cog:
print(cog.bounds)
>>> (683715.3266400001, 1718548.5702, 684593.2680000002, 1719064.90736)

print(cog.crs)
>>> EPSG:32620

print(cog.geographic_bounds)
>>> (-61.287001876638215, 15.537756794450583, -61.27877967704677, 15.542486503997608)
```

* Use `RIO_TILER_MAX_THREADS` environment variable instead of `MAX_THREADS` (author @rodrigoalmeida94, https://github.com/cogeotiff/rio-tiler/pull/432)
* remove `band_expression` in `rio_tiler.io.base.MultiBandReader` (https://github.com/cogeotiff/rio-tiler/pull/433)
* change `asset_expression` input type from `str` to `Dict[str, str]` in `rio_tiler.io.base.MultiBaseReader` (https://github.com/cogeotiff/rio-tiler/pull/434)

```python
# before
with STACReader("mystac.json") as stac:
img = stac.preview(
assets=("data1", "data2"),
asset_expression="b1*2", # expression was applied to each asset
)

# now
with STACReader("mystac.json") as stac:
img = stac.preview(
assets=("data1", "data2"),
asset_expression={"data1": "b1*2", "data2": "b2*100"}, # we can now pass per asset expression
)
```

* add `asset_indexes` in `rio_tiler.io.base.MultiBaseReader`, which replaces `indexes`. (https://github.com/cogeotiff/rio-tiler/pull/434)

```python
# before
with STACReader("mystac.json") as stac:
img = stac.preview(
assets=("data1", "data2"),
indexes=(1,), # indexes was applied to each asset
)

# now
with STACReader("mystac.json") as stac:
img = stac.preview(
assets=("data1", "data2"),
asset_indexes={"data1": 1, "data2": 2}, # we can now pass per asset indexes
)
```

# 2.1.3 (2021-09-14)

* Make sure output data is of type `Uint8` when applying a colormap (https://github.com/cogeotiff/rio-tiler/pull/423)
Expand Down
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ At the low level, `rio-tiler` is *just* a wrapper around the [rasterio.vrt.Warpe

with STACReader("item.json") as stac:
print(stac.assets) # available asset
img = stac.tile(x, y, z, assets="asset1", indexes=(1, 2, 3)) # read tile for asset1 and indexes 1,2,3
img = stac.tile(x, y, z, assets=("asset1", "asset2", "asset3",), indexes=(1,)) # create an image from assets 1,2,3 using their first band
img = stac.tile( # read tile for asset1 and indexes 1,2,3
x,
y,
z,
assets="asset1",
indexes=(1, 2, 3),
)

img = stac.tile( # create an image from assets 1,2,3 using their first band
x,
y,
z,
assets=("asset1", "asset2", "asset3",),
asset_indexes={"asset1": 1, "asset2": 1, "asset3": 1},
)
```

- [Mosaic](https://cogeotiff.github.io/rio-tiler/mosaic/) (merging or stacking)
Expand Down Expand Up @@ -136,26 +149,6 @@ $ pip install -U pip
$ pip install -e .
```

#### GDAL>=3.0 / PROJ>=6.0 performances issue

`rio-tiler` is often used for dynamic tiling, where we need to perform small tasks involving cropping and reprojecting the input data. Starting with GDAL>=3.0 the project shifted to PROJ>=6, which introduced new ways to store projection metadata (using a SQLite database and/or cloud stored grids). This change introduced a performance regression as mentioned in https://mapserver.gis.umn.edu/id/development/rfc/ms-rfc-126.html:

> using naively the equivalent calls proj_create_crs_to_crs() + proj_trans() would be a major performance killer, since proj_create_crs_to_crs() can take a time in the order of 100 milliseconds in the most complex situations.

We believe the issue reported in [issues/346](https://github.com/cogeotiff/rio-tiler/issues/346) is in fact due to :point_up:.

To get the best performances out of `rio-tiler` we recommend for now to use GDAL **2.4** until a solution can be found in GDAL or in PROJ.

Note: Starting with rasterio 1.2.0, rasterio's wheels are distributed with GDAL 3.2 and thus we recommend using rasterio==1.1.8 if using the default wheels, which include GDAL 2.4.

Links:

- http://rgdal.r-forge.r-project.org/articles/PROJ6_GDAL3.html
- https://mapserver.gis.umn.edu/id/development/rfc/ms-rfc-126.html
- https://github.com/OSGeo/gdal/issues/3470
- https://github.com/OSGeo/gdal/issues/1662


## Plugins

#### [**rio-tiler-pds**][rio-tiler-pds]
Expand Down
Loading