mirror of
https://github.com/rasterio/rasterio.git
synced 2026-02-01 14:34:43 +00:00
test windowed masks
This commit is contained in:
parent
2150030160
commit
151e2b7a53
@ -1,9 +1,8 @@
|
||||
"""
|
||||
Tests of band mask creation, both .msk sidecar and internal.
|
||||
|
||||
See https://github.com/mapbox/rasterio/issues/293 for bug report.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import rasterio
|
||||
from rasterio.enums import MaskFlags
|
||||
|
||||
@ -51,3 +50,28 @@ def test_create_sidecar_mask(data):
|
||||
# Check the .msk file, too.
|
||||
with rasterio.open(str(data.join('RGB.byte.tif.msk'))) as msk:
|
||||
assert (mask == msk.read(1, masked=False)).all()
|
||||
|
||||
|
||||
def test_create_mask_windowed_sidecar(data):
|
||||
"""Writing masks by window succeeds with sidecar mask
|
||||
"""
|
||||
with rasterio.Env(GDAL_TIFF_INTERNAL_MASK=False):
|
||||
with rasterio.open(str(data.join('RGB.byte.tif')), 'r+') as dst:
|
||||
for ij, window in dst.block_windows():
|
||||
blue = dst.read(1, window=window, masked=False)
|
||||
mask = 255 * (blue == 0).astype('uint8')
|
||||
dst.write_mask(mask, window=window)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="https://github.com/mapbox/rasterio/issues/781")
|
||||
def test_create_mask_windowed_internal(data):
|
||||
"""Writing masks by window with internal mask
|
||||
Currently fails with
|
||||
rasterio.errors.RasterioIOError: Failed to get mask.
|
||||
"""
|
||||
with rasterio.Env(GDAL_TIFF_INTERNAL_MASK=True):
|
||||
with rasterio.open(str(data.join('RGB.byte.tif')), 'r+') as dst:
|
||||
for ij, window in dst.block_windows():
|
||||
blue = dst.read(1, window=window, masked=False)
|
||||
mask = 255 * (blue == 0).astype('uint8')
|
||||
dst.write_mask(mask, window=window)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user