mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
parent
4d79175b6c
commit
49938067bc
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
Binary file not shown.
@ -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
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user