def test_output_data(mp_tmpdir):
    'Check GeoTIFF as output data.'
    output_params = dict(grid='geodetic', format='GeoTIFF', path=mp_tmpdir, pixelbuffer=0, metatiling=1, bands=1, dtype='int16', delimiters=dict(bounds=Bounds((- 180.0), (- 90.0), 180.0, 90.0), effective_bounds=Bounds((- 180.439453125), (- 90.0), 180.439453125, 90.0), zoom=[5], process_bounds=Bounds((- 180.0), (- 90.0), 180.0, 90.0)))
    output = gtiff.OutputDataWriter(output_params)
    assert (output.path == mp_tmpdir)
    assert (output.file_extension == '.tif')
    tp = BufferedTilePyramid('geodetic')
    tile = tp.tile(5, 5, 5)
    assert (output.get_path(tile) == os.path.join(*[mp_tmpdir, '5', '5', ('5' + '.tif')]))
    try:
        temp_dir = os.path.join(*[mp_tmpdir, '5', '5'])
        output.prepare_path(tile)
        assert os.path.isdir(temp_dir)
    finally:
        shutil.rmtree(temp_dir, ignore_errors=True)
    assert isinstance(output.profile(tile), dict)
    try:
        data = (np.ones(((1,) + tile.shape)) * 128)
        output.write(tile, data)
        assert output.tiles_exist(tile)
        data = output.read(tile)
        assert isinstance(data, np.ndarray)
        assert (not data[0].mask.any())
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        data = output.read(tile)
        assert isinstance(data, np.ndarray)
        assert data[0].mask.all()
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        empty = output.empty(tile)
        assert isinstance(empty, ma.MaskedArray)
        assert (not empty.any())
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        output_params.update(compress='deflate', predictor=2)
        output = gtiff.OutputDataWriter(output_params)
        assert (output.profile(tile)['compress'] == 'deflate')
        assert (output.profile(tile)['predictor'] == 2)
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        with pytest.deprecated_call():
            output_params.update(compression='deflate', predictor=2)
            output = gtiff.OutputDataWriter(output_params)
            assert (output.profile(tile)['compress'] == 'deflate')
            assert (output.profile(tile)['predictor'] == 2)
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
Check GeoTIFF as output data.
def test_output_data(mp_tmpdir):
    
    output_params = dict(grid='geodetic', format='GeoTIFF', path=mp_tmpdir, pixelbuffer=0, metatiling=1, bands=1, dtype='int16', delimiters=dict(bounds=Bounds((- 180.0), (- 90.0), 180.0, 90.0), effective_bounds=Bounds((- 180.439453125), (- 90.0), 180.439453125, 90.0), zoom=[5], process_bounds=Bounds((- 180.0), (- 90.0), 180.0, 90.0)))
    output = gtiff.OutputDataWriter(output_params)
    assert (output.path == mp_tmpdir)
    assert (output.file_extension == '.tif')
    tp = BufferedTilePyramid('geodetic')
    tile = tp.tile(5, 5, 5)
    assert (output.get_path(tile) == os.path.join(*[mp_tmpdir, '5', '5', ('5' + '.tif')]))
    try:
        temp_dir = os.path.join(*[mp_tmpdir, '5', '5'])
        output.prepare_path(tile)
        assert os.path.isdir(temp_dir)
    finally:
        shutil.rmtree(temp_dir, ignore_errors=True)
    assert isinstance(output.profile(tile), dict)
    try:
        data = (np.ones(((1,) + tile.shape)) * 128)
        output.write(tile, data)
        assert output.tiles_exist(tile)
        data = output.read(tile)
        assert isinstance(data, np.ndarray)
        assert (not data[0].mask.any())
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        data = output.read(tile)
        assert isinstance(data, np.ndarray)
        assert data[0].mask.all()
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        empty = output.empty(tile)
        assert isinstance(empty, ma.MaskedArray)
        assert (not empty.any())
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        output_params.update(compress='deflate', predictor=2)
        output = gtiff.OutputDataWriter(output_params)
        assert (output.profile(tile)['compress'] == 'deflate')
        assert (output.profile(tile)['predictor'] == 2)
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)
    try:
        with pytest.deprecated_call():
            output_params.update(compression='deflate', predictor=2)
            output = gtiff.OutputDataWriter(output_params)
            assert (output.profile(tile)['compress'] == 'deflate')
            assert (output.profile(tile)['predictor'] == 2)
    finally:
        shutil.rmtree(mp_tmpdir, ignore_errors=True)