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

add warning when no materialized overview are found #386

Merged
merged 3 commits into from
Apr 17, 2021
Merged
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
Binary file added docs/img/vrt_tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions docs/supported_format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

`rio-tiler` can work with all raster formats supported by [GDAL](https://gdal.org). That's beeing said, `rio-tiler` works better with data format that supports **partial reading**, like [Cloud Optimized GeoTIFF](http://cogeo.org).

On interesting feature of Cloud Optimized GeoTIFF is the internal overviews which enable fast preview of the data. For example, when using the `COGReader.preview` method, rio-tiler will only fetch the internal overviews instead of the whole data, to be able to contruct the output array. Doing this reduce the amount of data transfert and thus increase the process speed.

### VRT

GDAL's [Virtual format](https://gdal.org/drivers/raster/vrt.html#raster-vrt) is also supported by rio-tiler.

!!! warnings
Map Tile reading from VRT might not be efficient if overviews are not present, because GDAL will try to open a lot of files.

![](img/vrt_tile.png)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ nav:
- Models: 'models.md'
- Mosaic: 'mosaic.md'
- Colormaps: 'colormap.md'
- Supported file formats: 'supported_format.md'
- Advanced Topics:
- Read Polygon-shaped regions: 'advanced/feature.md'
- Base classes and custom readers: 'advanced/custom_readers.md'
Expand Down
10 changes: 9 additions & 1 deletion rio_tiler/io/cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from .. import reader
from ..constants import WEB_MERCATOR_TMS, WGS84_CRS, BBox, Indexes, NoData
from ..errors import ExpressionMixingWarning, TileOutsideBounds
from ..errors import ExpressionMixingWarning, NoOverviewWarning, TileOutsideBounds
from ..expression import apply_expression, parse_expression
from ..models import ImageData, ImageStatistics, Info
from ..utils import create_cutline, has_alpha_band, has_mask_band
Expand Down Expand Up @@ -109,6 +109,14 @@ def __attrs_post_init__(self):
if self.colormap is None:
self._get_colormap()

if min(
self.dataset.width, self.dataset.height
) > 512 and not self.dataset.overviews(1):
warnings.warn(
"The dataset has no Overviews. rio-tiler performances might be impacted.",
NoOverviewWarning,
)

def close(self):
"""Close rasterio dataset."""
if self.filepath:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_io_cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from rio_tiler.errors import (
AlphaBandWarning,
ExpressionMixingWarning,
NoOverviewWarning,
TileOutsideBounds,
)
from rio_tiler.io import COGReader, GCPCOGReader
Expand All @@ -29,6 +30,7 @@
COG_GCPS = os.path.join(PREFIX, "cog_gcps.tif")
COG_DLINE = os.path.join(PREFIX, "cog_dateline.tif")
COG_EARTH = os.path.join(PREFIX, "cog_fullearth.tif")
GEOTIFF = os.path.join(PREFIX, "nocog.tif")

KEY_ALPHA = "hro_sources/colorado/201404_13SED190110_201404_0x1500m_CL_1_alpha.tif"
COG_ALPHA = os.path.join(PREFIX, "my-bucket", KEY_ALPHA)
Expand Down Expand Up @@ -672,3 +674,10 @@ def test_read():

img = cog.read(indexes=(1, 1,))
assert img.data.shape == (2, 2667, 2658)


def test_no_overviews():
"""Should warns when no overviews are found."""
with pytest.warns(NoOverviewWarning):
with COGReader(GEOTIFF):
pass