diff --git a/rasterio/_base.pyx b/rasterio/_base.pyx index bdd48fe70..f18109a75 100644 --- a/rasterio/_base.pyx +++ b/rasterio/_base.pyx @@ -1062,9 +1062,6 @@ cdef class DatasetBase(object): value : iter A sequence of ``ColorInterp.``. """ - - value = tuple(value) - if self.mode == 'r': raise RasterioIOError( "Can only set color interpretation when dataset is " @@ -1077,7 +1074,7 @@ cdef class DatasetBase(object): for bidx, ci in zip(self.indexes, value): exc_wrap_int( - GDALSetRasterColorInterpretation(self.band(bidx), ci.value)) + GDALSetRasterColorInterpretation(self.band(bidx), ci.value)) def colormap(self, bidx): """Returns a dict containing the colormap for a band or None.""" diff --git a/rasterio/rio/mask.py b/rasterio/rio/mask.py index d2e65098b..0654701ae 100644 --- a/rasterio/rio/mask.py +++ b/rasterio/rio/mask.py @@ -111,17 +111,17 @@ def mask( 'input raster', param=crop, param_hint='--crop') - else: # pragma: no cover + else: # pragma: no cover raise e - meta = src.meta.copy() - meta.update(**creation_options) - meta.update({ + profile = src.profile + profile.update(**creation_options) + profile.update({ 'driver': driver, 'height': out_image.shape[1], 'width': out_image.shape[2], 'transform': out_transform }) - with rasterio.open(output, 'w', **meta) as out: + with rasterio.open(output, 'w', **profile) as out: out.write(out_image) diff --git a/tests/test_colorinterp.py b/tests/test_colorinterp.py index 4c1fdfd43..8ffd4c73a 100644 --- a/tests/test_colorinterp.py +++ b/tests/test_colorinterp.py @@ -86,9 +86,11 @@ def test_set_colorinterp(path_rgba_byte_tif, tmpdir, dtype): @pytest.mark.parametrize("ci", ColorInterp.__members__.values()) def test_set_colorinterp_all(path_4band_no_colorinterp, ci): - """Test setting with all color interpretations.""" + if ci.value == 1: + pytest.xfail("Setting colorinterp to gray fails with GDAL 2.3, see https://github.com/mapbox/rasterio/issues/1234") + with rasterio.open(path_4band_no_colorinterp, 'r+') as src: all_ci = list(src.colorinterp) all_ci[1] = ci diff --git a/tests/test_rio_mask.py b/tests/test_rio_mask.py index 6603a0540..d8dc08ce0 100644 --- a/tests/test_rio_mask.py +++ b/tests/test_rio_mask.py @@ -10,11 +10,15 @@ import rasterio from rasterio.crs import CRS +from rasterio.env import GDALVersion from rasterio.rio.main import main_group from .conftest import requires_gdal22 +gdal_version = GDALVersion.runtime() + + def test_mask(runner, tmpdir, basic_feature, basic_image_2x2, pixelated_image_file): @@ -160,7 +164,9 @@ def test_mask_invalid_geojson(runner, tmpdir, pixelated_image_file): assert 'Invalid GeoJSON' in result.output - +@pytest.mark.xfail( + gdal_version.at_least('2.3'), + reason="Test only applicable to GDAL < 2.3") @requires_gdal22( reason="This test is sensitive to pixel values and requires GDAL 2.2+") def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image): @@ -173,7 +179,7 @@ def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image): outfilename = str(tmpdir.join('pixelated_image.tif')) kwargs = { "crs": CRS({'init': 'epsg:4326'}), - "transform": affine.Affine(1, 0, 0, 0, -1, 0), + "transform": affine.Affine(1.0, 0, 0, 0, -1.0, 0), "count": 1, "dtype": rasterio.uint8, "driver": "GTiff", @@ -192,6 +198,7 @@ def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image): main_group, ['mask', outfilename, output, '--crop', '--geojson-mask', '-'], input=json.dumps(basic_feature)) + assert result.exit_code == 0 assert os.path.exists(output) with rasterio.open(output) as out: diff --git a/tests/test_transform.py b/tests/test_transform.py index f568c4f1c..2fa1989ad 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -2,10 +2,14 @@ import pytest import rasterio from rasterio import transform +from rasterio.env import GDALVersion from rasterio.transform import xy, rowcol from rasterio.windows import Window +gdal_version = GDALVersion.runtime() + + def test_window_transform(): with rasterio.open('tests/data/RGB.byte.tif') as src: assert src.window_transform(((0, None), (0, None))) == src.transform @@ -78,6 +82,9 @@ def test_affine_roundtrip(tmpdir): assert out.transform == out_affine +@pytest.mark.skipif( + gdal_version.at_least('2.3'), + reason="Test only applicable to GDAL < 2.3") def test_affine_identity(tmpdir): """ Setting a transform with absolute values equivalent to Affine.identity()