diff --git a/rasterio/_base.pyx b/rasterio/_base.pyx index a5ef3697..04f454d0 100644 --- a/rasterio/_base.pyx +++ b/rasterio/_base.pyx @@ -448,6 +448,10 @@ cdef class DatasetReader(object): else: return None + @property + def is_tiled(self): + return self.block_shapes[0][1] != self.width + property profile: """Basic metadata and creation options of this dataset. @@ -457,10 +461,13 @@ cdef class DatasetReader(object): def __get__(self): m = self.meta m.update(self.tags(ns='rio_creation_kwds')) - m.update( - blockxsize=self.block_shapes[0][1], - blockysize=self.block_shapes[0][0], - tiled=self.block_shapes[0][1] != self.width) + if self.is_tiled: + m.update( + blockxsize=self.block_shapes[0][1], + blockysize=self.block_shapes[0][0], + tiled=True) + else: + m.update(tiled=False) if self.compression: m['compress'] = self.compression.name if self.interleaving: diff --git a/rasterio/rio/merge.py b/rasterio/rio/merge.py index d816ac74..5e637c87 100644 --- a/rasterio/rio/merge.py +++ b/rasterio/rio/merge.py @@ -73,6 +73,7 @@ def merge(ctx, files, output, driver, bounds, res, nodata, force_overwrite, profile['height'] = dest.shape[1] profile['width'] = dest.shape[2] profile['driver'] = driver + profile.update(**creation_options) with rasterio.open(output, 'w', **profile) as dst: diff --git a/rasterio/rio/options.py b/rasterio/rio/options.py index 0e5aeb82..dfccd54f 100644 --- a/rasterio/rio/options.py +++ b/rasterio/rio/options.py @@ -73,6 +73,8 @@ def _cb_key_val(ctx, param, value): raise click.BadParameter("Invalid syntax for KEY=VAL arg: {}".format(pair)) else: k, v = pair.split('=', 1) + k = k.lower() + v = v.lower() out[k] = v return out diff --git a/tests/data/shade.tif b/tests/data/shade.tif index 6a5a2262..9ea0f3f0 100644 Binary files a/tests/data/shade.tif and b/tests/data/shade.tif differ diff --git a/tests/test_options.py b/tests/test_options.py index 38ee698b..03bb15d2 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -7,7 +7,7 @@ def test_cb_key_val(): pairs = ['KEY=val', '1=='] expected = { - 'KEY': 'val', + 'key': 'val', '1': '=', } assert options._cb_key_val(None, None, pairs) == expected diff --git a/tests/test_profile.py b/tests/test_profile.py index 32979c4d..07cc2cf3 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -79,11 +79,26 @@ def test_profile_overlay(): assert kwds['count'] == 3 -def test_dataset_profile_property(data): +def test_dataset_profile_property_tiled(data): + """An tiled dataset's profile has block sizes""" + with rasterio.open('tests/data/shade.tif') as src: + assert src.profile['blockxsize'] == 256 + assert src.profile['blockysize'] == 256 + assert src.profile['tiled'] == True + + +def test_dataset_profile_property_untiled(data): + """An untiled dataset's profile has no block sizes""" + with rasterio.open('tests/data/RGB.byte.tif') as src: + assert 'blockxsize' not in src.profile + assert 'blockysize' not in src.profile + assert src.profile['tiled'] == False + + +def test_dataset_profile_creation_kwds(data): + """Updated creation keyword tags appear in profile""" tiffile = str(data.join('RGB.byte.tif')) with rasterio.open(tiffile, 'r+') as src: src.update_tags(ns='rio_creation_kwds', foo='bar') - assert src.profile['blockxsize'] == 791 - assert src.profile['blockysize'] == 3 assert src.profile['tiled'] == False assert src.profile['foo'] == 'bar'