Skip to content

Commit

Permalink
Handle string values for tiled kwarg
Browse files Browse the repository at this point in the history
Resolves #2085
  • Loading branch information
Sean Gillies committed Jan 24, 2021
1 parent 7f7bbec commit beb964f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ New features:

Bug fixes since 1.2b4:

- Fix dataset constructor so that tiled=False does the right thing (#2085).
- Allow WarpedVRT to default to using a source dataset's GCPs for
georeferencing (#2086).
- Ensure that error handling environment is closed only after its dataset
Expand Down
2 changes: 2 additions & 0 deletions rasterio/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ cdef class DatasetWriterBase(DatasetReaderBase):
# "tiled" affects the meaning of blocksize, so we need it
# before iterating.
tiled = kwargs.pop("tiled", False) or kwargs.pop("TILED", False)
if isinstance(tiled, str):
tiled = (tiled.lower() in ("true", "yes"))

if tiled:
blockxsize = kwargs.get("blockxsize", None)
Expand Down
1 change: 1 addition & 0 deletions rasterio/rio/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def convert(

profile.update(**creation_options)

# "tiled" is special
with rasterio.open(outputfile, 'w', **profile) as dst:

data = src.read()
Expand Down
12 changes: 12 additions & 0 deletions tests/test_rio_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ def test_clip_overwrite_with_option(runner, tmpdir):

# Tests: format and type conversion, --format and --dtype


def test_tiled(tmpdir, runner):
outputname = str(tmpdir.join("test.tif"))
result = runner.invoke(
main_group,
["convert", "tests/data/RGB.byte.tif", outputname, "--co", "tiled=false"],
)
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert not src.is_tiled


def test_format(tmpdir, runner):
outputname = str(tmpdir.join('test.jpg'))
result = runner.invoke(
Expand Down

0 comments on commit beb964f

Please sign in to comment.