Skip to content

Commit

Permalink
use same resampling for mask (#106)
Browse files Browse the repository at this point in the history
* use same resampling for mask

* update version [skip ci]
  • Loading branch information
vincentsarago authored May 10, 2019
1 parent 2bf9f14 commit 156b0a8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
1.2.5 (2019-05-16)
1.2.6 (2019-05-10)
------------------

- Use same resampling method for mask and for data (#105)


1.2.5 (2019-05-08)
------------------

- add tile_edge_padding option to be passed to rio_tiler.utils._tile_read to reduce sharp edges that occur due to resampling (#104)
Expand Down
2 changes: 1 addition & 1 deletion rio_tiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""rio-tiler."""

__version__ = "1.2.5"
__version__ = "1.2.6"
6 changes: 5 additions & 1 deletion rio_tiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ def _tile_read(
resampling=Resampling[resampling_method],
)

mask = vrt.dataset_mask(out_shape=(tilesize, tilesize), window=out_window)
mask = vrt.dataset_mask(
out_shape=(tilesize, tilesize),
window=out_window,
resampling=Resampling[resampling_method],
)

return data, mask

Expand Down
16 changes: 16 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,19 @@ def test_aligned_with_internaltile():

with rasterio.open(COG_WEB_TILED) as src_dst:
assert utils._requested_tile_aligned_with_internal_tile(src_dst, bounds, 256)


def test_tile_read_validMask():
"""Dataset mask should be the same as the actual mask."""
address = "{}_B2.TIF".format(LANDSAT_PATH)

bounds = (
-8844681.416934313,
3757032.814272982,
-8766409.899970293,
3835304.331237001,
)
tilesize = 128
arr, mask = utils.tile_read(address, bounds, tilesize, nodata=0)
masknodata = (arr[0] != 0).astype(np.uint8) * 255
np.testing.assert_array_equal(mask, masknodata)

0 comments on commit 156b0a8

Please sign in to comment.