Skip to content

Commit

Permalink
Resolve #1471, update change log and version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean C. Gillies committed Sep 19, 2018
1 parent f627e14 commit 09edba6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changes
=======

1.0.5 (2018-09-19)
------------------

Bug fixes:

- The fill value for boundless reads was ignored in Rasterio versions 1-1.0.4
but now applies (#1471).
- An invalid shortcut has been eliminated a Rasterio now prroduces a proper
mask in the boundless masked read case (#1449).
- Loss of a row or column in geometry_window() and mask() has been fixed
(#1472).

1.0.4 (2018-09-17)
------------------

Expand Down
2 changes: 1 addition & 1 deletion rasterio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def emit(self, record):


__all__ = ['band', 'open', 'pad', 'Env']
__version__ = "1.0.4"
__version__ = "1.0.5"
__gdal_version__ = gdal_version()

# Rasterio attaches NullHandler to the 'rasterio' logger and its
Expand Down
2 changes: 1 addition & 1 deletion rasterio/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ cdef class DatasetReaderBase(DatasetBase):
else:

vrt_doc = _boundless_vrt_doc(
self, nodata=ndv, width=max(self.width, window.width) + 1,
self, nodata=ndv, hidenodata=bool(fill_value), width=max(self.width, window.width) + 1,
height=max(self.height, window.height) + 1,
transform=self.window_transform(window)).decode('ascii')

Expand Down
6 changes: 5 additions & 1 deletion rasterio/vrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def close(self):
self.stop()


def _boundless_vrt_doc(src_dataset, nodata=None, width=None, height=None, transform=None):
def _boundless_vrt_doc(src_dataset, nodata=None, hidenodata=False, width=None, height=None, transform=None):
"""Make a VRT XML document."""

nodata = nodata or src_dataset.nodata
Expand All @@ -94,6 +94,10 @@ def _boundless_vrt_doc(src_dataset, nodata=None, width=None, height=None, transf
nodatavalue = ET.SubElement(vrtrasterband, 'NoDataValue')
nodatavalue.text = str(nodata)

if hidenodata:
hidenodatavalue = ET.SubElement(vrtrasterband, 'HideNoDataValue')
hidenodatavalue.text = "1"

colorinterp = ET.SubElement(vrtrasterband, 'ColorInterp')
colorinterp.text = ci.name.capitalize()

Expand Down
10 changes: 10 additions & 0 deletions tests/test_boundless_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ def test_boundless_mask_not_all_valid():
assert masked.mask[:, -1].all()
assert masked.mask[0, :].all()
assert masked.mask[-1, :].all()


def test_boundless_fill_value():
"""Confirm resolution of issue #1471"""
with rasterio.open("tests/data/red.tif") as src:
filled = src.read(1, boundless=True, fill_value=5, window=Window(-1, -1, 66, 66))
assert (filled[:, 0] == 5).all()
assert (filled[:, -1] == 5).all()
assert (filled[0, :] == 5).all()
assert (filled[-1, :] == 5).all()

0 comments on commit 09edba6

Please sign in to comment.