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

switch to morecantile3 #418

Merged
merged 7 commits into from
Sep 14, 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
2 changes: 1 addition & 1 deletion .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 Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 3.0.0 (TDB)

**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)

# 2.1.2 (2021-08-10)

* update type information for mosaics functions (https://github.com/cogeotiff/rio-tiler/pull/409)
Expand Down
2 changes: 1 addition & 1 deletion rio_tiler/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def tile_exists(self, tile_z: int, tile_x: int, tile_y: int) -> bool:

"""
tile = Tile(x=tile_x, y=tile_y, z=tile_z)
tile_bounds = self.tms.bounds(*tile)
tile_bounds = self.tms.bounds(tile)
return (
(tile_bounds[0] < self.bounds[2])
and (tile_bounds[2] > self.bounds[0])
Expand Down
8 changes: 4 additions & 4 deletions rio_tiler/io/cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def __exit__(self, exc_type, exc_value, traceback):

def get_zooms(self, tilesize: int = 256) -> Tuple[int, int]:
"""Calculate raster min/max zoom level."""
if self.dataset.crs != self.tms.crs:
if self.dataset.crs != self.tms.rasterio_crs:
dst_affine, w, h = calculate_default_transform(
self.dataset.crs,
self.tms.crs,
self.tms.rasterio_crs,
self.dataset.width,
self.dataset.height,
*self.dataset.bounds,
Expand Down Expand Up @@ -281,7 +281,7 @@ def tile(
f"Tile {tile_z}/{tile_x}/{tile_y} is outside {self.filepath} bounds"
)

tile_bounds = self.tms.xy_bounds(*Tile(x=tile_x, y=tile_y, z=tile_z))
tile_bounds = self.tms.xy_bounds(Tile(x=tile_x, y=tile_y, z=tile_z))
if tile_buffer:
x_res = (tile_bounds[2] - tile_bounds[0]) / tilesize
y_res = (tile_bounds[3] - tile_bounds[1]) / tilesize
Expand All @@ -295,7 +295,7 @@ def tile(

return self.part(
tile_bounds,
dst_crs=self.tms.crs,
dst_crs=self.tms.rasterio_crs,
bounds_crs=None,
height=tilesize,
width=tilesize,
Expand Down
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"boto3",
"numexpr",
"numpy",
"morecantile>=2.1,<2.2",
"morecantile>=3.0.0a0,<3.1",
"pydantic",
"pystac>=0.5.3",
"rasterio>=1.1.7",
Expand All @@ -21,13 +21,19 @@
]

extra_reqs = {
"test": ["pytest", "pytest-asyncio", "pytest-benchmark", "pytest-cov", "rio-cogeo"],
"test": [
"pytest",
"pytest-asyncio",
"pytest-benchmark",
"pytest-cov",
"rio-cogeo @ git+https://github.com/cogeotiff/rio-cogeo.git@morecantileV3", # TODO: replace with rio-cogeo>=3.0
],
"dev": [
"pytest",
"pytest-benchmark",
"pytest-cov",
"pytest-asyncio",
"rio-cogeo",
"rio-cogeo @ git+https://github.com/cogeotiff/rio-cogeo.git@morecantileV3", # TODO: replace with rio-cogeo>=3.0
"pre-commit",
],
"docs": ["nbconvert", "mkdocs", "mkdocs-material", "pygments", "mkdocs-jupyter"],
Expand All @@ -36,7 +42,7 @@
setup(
name="rio-tiler",
version="2.1.2",
python_requires=">=3.6",
python_requires=">=3.7",
description="User friendly Rasterio plugin to read raster datasets.",
long_description=readme,
long_description_content_type="text/markdown",
Expand All @@ -47,7 +53,6 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.6",
"Topic :: Scientific/Engineering :: GIS",
],
keywords="cog cogeotiff raster map tiles gdal rasterio raster-processing slippy-map",
Expand Down
Binary file modified tests/fixtures/cog_cmap.tif
Binary file not shown.
Binary file modified tests/fixtures/cog_dateline.tif
Binary file not shown.
20 changes: 17 additions & 3 deletions tests/test_io_cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,21 @@ def test_metadata_valid():
with COGReader(COG_CMAP) as cog:
assert cog.colormap
b1_stats = cog.metadata().statistics["1"]
assert b1_stats.histogram[1] == list(range(20))
assert b1_stats.histogram[1] == [
0.0,
1.0,
2.0,
3.0,
4.0,
5.0,
6.0,
7.0,
8.0,
10.0,
11.0,
12.0,
13.0,
]


def test_tile_valid_default():
Expand Down Expand Up @@ -655,10 +669,10 @@ def test_tile_read_extmask():
def test_dateline():
"""Read tile from data crossing the antimeridian."""
with COGReader(COG_DLINE) as cog:
img = cog.tile(1, 42, 7, tilesize=64)
img = cog.tile(0, 84, 8, tilesize=64)
assert img.data.shape == (1, 64, 64)

img = cog.tile(127, 42, 7, tilesize=64)
img = cog.tile(255, 84, 8, tilesize=64)
assert img.data.shape == (1, 64, 64)


Expand Down
14 changes: 1 addition & 13 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,6 @@ def test_point():
with pytest.raises(PointOutsideBounds):
reader.point(src_dst, [810000, 4100000], coord_crs=src_dst.crs)

with rasterio.open(COG_CMAP) as src_dst:
# Should return None when reading masked pixel
assert not reader.point(src_dst, [-95.530, 19.8882])[0]

# Should return value when not using Masked
assert reader.point(src_dst, [-95.530, 19.8882], masked=False)[0] == 0

# Checking nodata overwrite
assert (
reader.point(src_dst, [-95.530, 19.8882], masked=True, nodata=100)[0] == 0
)

with rasterio.open(S3_MASK_PATH) as src_dst:
# Test with COG + internal mask
assert not reader.point(src_dst, [-104.7753105, 38.953548])[0]
Expand All @@ -406,7 +394,7 @@ def test_metadata():
"""Should return correct metadata."""
with rasterio.open(COG_CMAP) as src_dst:
meta = reader.metadata(src_dst)
assert meta["dtype"] == "int8"
assert meta["dtype"] == "uint8"
assert meta["colorinterp"] == ["palette"]
assert not meta.get("scale")
assert not meta.get("ofsset")
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36,py37,py38,p39
envlist = py37,py38,p39

[testenv]
extras = test
Expand Down