Merge pull request #302 from mapbox/issue-301

Add missing keywords: blockxsize, blockysize, tiled
This commit is contained in:
Sean Gillies 2015-03-30 12:08:02 -06:00
commit 76e5fb7306
3 changed files with 36 additions and 1 deletions

View File

@ -1,6 +1,10 @@
Changes
=======
Maint next
----------
- Add missing blockxsize, blockysize, tiled keywords (#301).
0.19.0 (2015-03-25)
-------------------
- New rio-calc command (#175).

View File

@ -395,7 +395,10 @@ cdef class DatasetReader(object):
'count': self.count,
'crs': self.crs,
'transform': self.affine.to_gdal(),
'affine': self.affine }
'affine': self.affine,
'blockxsize': self.block_shapes[0][1],
'blockysize': self.block_shapes[0][0],
'tiled': self.block_shapes[0][1] != self.width }
self._read = True
return m

28
tests/test_meta.py Normal file
View File

@ -0,0 +1,28 @@
# Tests of dataset meta keywords and dataset creation
import rasterio
def test_blocksize_rgb(tmpdir):
with rasterio.open('tests/data/RGB.byte.tif') as src:
kwds = src.meta
assert kwds['blockxsize'] == 791
assert kwds['blockysize'] == 3
assert kwds['tiled'] is False
def test_blocksize_shade(tmpdir):
with rasterio.open('tests/data/shade.tif') as src:
kwds = src.meta
assert kwds['blockxsize'] == 1024
assert kwds['blockysize'] == 8
assert kwds['tiled'] is False
def test_copy_meta(tmpdir):
with rasterio.open('tests/data/RGB.byte.tif') as src:
kwds = src.meta
with rasterio.open(
str(tmpdir.join('test_copy_meta.tif')), 'w', **kwds) as dst:
assert dst.meta['count'] == 3
assert dst.meta['blockxsize'] == 791
assert dst.meta['blockysize'] == 3
assert dst.meta['tiled'] is False