Beispiel #1
0
def test_blockysize_guard(tmpdir):
    """blockysize can't be greater than image height."""
    tiffname = str(tmpdir.join('foo.tif'))
    with pytest.raises(ValueError):
        profile = default_gtiff_profile.copy()
        profile.update(count=1, width=256, height=128)
        rasterio.open(tiffname, 'w', **profile)
Beispiel #2
0
def test_blockysize_guard(tmpdir):
    """blockysize can't be greater than image height."""
    tiffname = str(tmpdir.join('foo.tif'))
    with pytest.raises(ValueError):
        profile = default_gtiff_profile.copy()
        profile.update(count=1, width=256, height=128)
        rasterio.open(tiffname, 'w', **profile)
Beispiel #3
0
def test_odd_blocksize_error(tmpdir, blocksizes):
    """For a tiled TIFF block sizes must be multiples of 16"""
    tempfile = str(tmpdir.join("test.tif"))
    profile = default_gtiff_profile.copy()
    profile.update(height=64, width=64, count=1, **blocksizes)
    with pytest.raises(RasterBlockError):
        rasterio.open(tempfile, "w", **profile)
Beispiel #4
0
def test_block_windows_bigger_blocksize(tmpdir, blocksize):
    """Ensure that block sizes greater than raster size are ok"""
    tempfile = str(tmpdir.join("test.tif"))
    profile = default_gtiff_profile.copy()
    profile.update(height=16,
                   width=16,
                   count=1,
                   blockxsize=blocksize,
                   blockysize=blocksize)
    with rasterio.open(tempfile, "w", **profile) as dst:
        assert dst.is_tiled
        for ij, window in dst.block_windows():
            dst.write(np.ones((1, 1), dtype="uint8"), 1, window=window)

    with rasterio.open(tempfile) as dst:
        assert list(dst.block_windows()) == [((0, 0),
                                              windows.Window(0, 0, 16, 16))]
        assert (dst.read(1) == 1).all()
def test_open_with_profile(tmpdir):
    tiffname = str(tmpdir.join('foo.tif'))
    profile = default_gtiff_profile.copy()
    profile.update(count=1, width=256, height=256)
    with rasterio.open(tiffname, 'w', **profile) as dst:
        assert not dst.closed
Beispiel #6
0
def test_open_with_profile(tmpdir):
    tiffname = str(tmpdir.join('foo.tif'))
    profile = default_gtiff_profile.copy()
    profile.update(count=1, width=256, height=256)
    with rasterio.open(tiffname, 'w', **profile) as dst:
        assert not dst.closed
Beispiel #7
0
def test_update_vfs(tmpdir, mode):
    """VFS datasets can not be created or updated"""
    profile = default_gtiff_profile.copy()
    profile.update(count=1, width=1, height=1)
    with pytest.raises(TypeError):
        rasterio.open('zip://{0}'.format(tmpdir), mode, **profile)