Skip to content
Commits on Source (5)
Changes
=======
1.0.7 (2018-09-26)
------------------
Bug fixes:
- Use the non-resolving path form of files_inout_arg in rio-convert and
rio-shapes (#999).
- Filling the empty regions of boundless reads was too slow in some cases and
a faster solution has been found (#1480).
- Require cligj>=0.5 for compatibility with click 7.0.
- Precisely specify CLI option and argument names for click 6.x and 7.0
compatibility.
1.0.6 (2018-09-24)
------------------
......
rasterio (1.0.7-1) unstable; urgency=medium
* Team upload.
* New upstream release.
* Bump minimum required cligj to 0.5.
-- Bas Couwenberg <sebastic@debian.org> Thu, 27 Sep 2018 07:37:43 +0200
rasterio (1.0.6-1) unstable; urgency=medium
* Team upload.
......
......@@ -15,7 +15,7 @@ Build-Depends: debhelper (>= 9),
python-attr (>= 16.0.0),
python-boto3,
python-click-plugins,
python-cligj (>= 0.2),
python-cligj (>= 0.5),
python-enum34,
python-hypothesis,
python-numpy (>= 1.10),
......@@ -29,7 +29,7 @@ Build-Depends: debhelper (>= 9),
python3-attr (>= 16.0.0),
python3-boto3,
python3-click-plugins,
python3-cligj (>= 0.2),
python3-cligj (>= 0.5),
python3-hypothesis,
python3-numpy (>= 1.10),
python3-packaging,
......
......@@ -43,7 +43,7 @@ import rasterio.path
__all__ = ['band', 'open', 'pad', 'Env']
__version__ = "1.0.6"
__version__ = "1.0.7"
__gdal_version__ = gdal_version()
# Rasterio attaches NullHandler to the 'rasterio' logger and its
......
......@@ -12,6 +12,7 @@ cdef class DatasetReaderBase(DatasetBase):
cdef class DatasetWriterBase(DatasetReaderBase):
cdef readonly object _init_dtype
cdef readonly object _init_nodata
cdef readonly object _init_gcps
cdef readonly object _options
......
......@@ -367,8 +367,22 @@ cdef class DatasetReaderBase(DatasetBase):
# in order to use GDAL's windowing and compositing logic.
else:
if fill_value is not None:
dtype = self.dtypes[0]
bg_path = UnparsedPath('/vsimem/bg{}.tif'.format(uuid.uuid4()))
with DatasetWriterBase(
bg_path, 'w',
driver='GTiff', count=self.count, height=3, width=3,
dtype=dtype, crs=None, transform=None) as bg_dataset:
bg_dataset.write(
np.full((self.count, 3, 3), fill_value, dtype=dtype))
bg_dataset = DatasetReaderBase(bg_path)
else:
bg_dataset = None
vrt_doc = _boundless_vrt_doc(
self, nodata=ndv, width=max(self.width, window.width) + 1,
self, nodata=ndv, background=bg_dataset,
width=max(self.width, window.width) + 1,
height=max(self.height, window.height) + 1,
transform=self.window_transform(window)).decode('ascii')
......@@ -376,13 +390,14 @@ cdef class DatasetReaderBase(DatasetBase):
vrt_kwds = {'driver': 'VRT'}
else:
vrt_kwds = {}
with DatasetReaderBase(UnparsedPath(vrt_doc), **vrt_kwds) as vrt:
out = vrt._read(
indexes, out, Window(0, 0, window.width, window.height),
None, resampling=resampling)
if masked or fill_value is not None:
if masked:
mask = np.zeros(out.shape, 'uint8')
mask = ~vrt._read(
indexes, mask, Window(0, 0, window.width, window.height), None, masks=True).astype('bool')
......@@ -398,8 +413,8 @@ cdef class DatasetReaderBase(DatasetBase):
out = np.ma.array(out, **kwds)
if not masked:
out = out.filled(fill_value)
if bg_dataset is not None:
bg_dataset.close()
if return2d:
out.shape = out.shape[1:]
......
......@@ -11,12 +11,7 @@ from rasterio.rio.helpers import resolve_inout
@click.command(short_help="Copy and convert raster dataset.")
@click.argument(
'files',
nargs=-1,
type=click.Path(resolve_path=True),
required=True,
metavar="INPUT OUTPUT")
@options.files_inout_arg
@options.output_opt
@format_opt
@options.dtype_opt
......
......@@ -52,7 +52,7 @@ from rasterio.rio import options
"(use --bidx).")
@click.option('--subdatasets', 'meta_member', flag_value='subdatasets',
help="Print subdataset identifiers.")
@click.option('-v', '--tell-me-more', '--verbose', is_flag=True,
@click.option('-v', '--tell-me-more', '--verbose', 'verbose', is_flag=True,
help="Output extra information.")
@options.bidx_opt
@options.masked_opt
......
......@@ -30,7 +30,7 @@ def files_handler(ctx, param, value):
files_inout_arg = click.argument(
'files',
nargs=-1,
type=click.Path(resolve_path=True),
type=click.Path(),
metavar="INPUTS... OUTPUT",
callback=files_handler)
......
......@@ -14,7 +14,7 @@ from rasterio.errors import DriverRegistrationError, RasterioIOError
prompt="Are you sure you want to delete the dataset?",
expose_value=True)
@click.option(
'-f', '--format', '--driver',
'-f', '--format', '--driver', 'driver',
help="Explicitly delete with this driver rather than probing for the "
"appropriate driver.")
def rm(path, yes, driver):
......
......@@ -16,25 +16,6 @@ from rasterio.rio.helpers import write_features
logger = logging.getLogger(__name__)
# Common options used below
# Unlike the version in cligj, this one doesn't require values.
files_inout_arg = click.argument(
'files',
nargs=-1,
type=click.Path(resolve_path=True),
metavar="INPUTS... OUTPUT",
callback=options.files_inout_handler)
all_touched_opt = click.option(
'-a', '--all', '--all_touched', 'all_touched',
is_flag=True,
default=False,
help='Use all pixels touched by features, otherwise (default) use only '
'pixels whose center is within the polygon or that are selected by '
'Bresenhams line algorithm')
@click.command(short_help="Write shapes extracted from bands or masks.")
@options.file_in_arg
@options.output_opt
......
......@@ -44,7 +44,7 @@ MAX_OUTPUT_HEIGHT = 100000
help="Determine output extent from source bounds: left bottom right top "
". Cannot be used with destination --bounds")
@click.option(
'--bounds', '--dst-bounds', nargs=4, type=float, default=None,
'--bounds', '--dst-bounds', 'dst_bounds', nargs=4, type=float, default=None,
help="Determine output extent from destination bounds: left bottom right top")
@options.resolution_opt
@click.option('--resampling',
......
......@@ -69,8 +69,24 @@ class WarpedVRT(WarpedVRTReaderBase, WindowMethodsMixin,
self.stop()
def _boundless_vrt_doc(src_dataset, nodata=None, hidenodata=False, width=None, height=None, transform=None):
"""Make a VRT XML document."""
def _boundless_vrt_doc(
src_dataset, nodata=None, background=None, hidenodata=False,
width=None, height=None, transform=None):
"""Make a VRT XML document.
Parameters
----------
src_dataset : Dataset
The dataset to wrap.
background : Dataset, optional
A dataset that provides the optional VRT background. NB: this dataset
must have the same number of bands as the src_dataset.
Returns
-------
bytes
An ascii-encoded string (an ElementTree detail)
"""
nodata = nodata or src_dataset.nodata
width = width or src_dataset.width
......@@ -101,12 +117,34 @@ def _boundless_vrt_doc(src_dataset, nodata=None, hidenodata=False, width=None, h
colorinterp = ET.SubElement(vrtrasterband, 'ColorInterp')
colorinterp.text = ci.name.capitalize()
if background is not None:
simplesource = ET.SubElement(vrtrasterband, 'SimpleSource')
sourcefilename = ET.SubElement(simplesource, 'SourceFilename')
sourcefilename.attrib['relativeToVRT'] = "0"
sourcefilename.text = vsi_path(parse_path(background.name))
sourceband = ET.SubElement(simplesource, 'SourceBand')
sourceband.text = str(bidx)
sourceproperties = ET.SubElement(simplesource, 'SourceProperties')
sourceproperties.attrib['RasterXSize'] = str(width)
sourceproperties.attrib['RasterYSize'] = str(height)
sourceproperties.attrib['dataType'] = _gdal_typename(dtype)
sourceproperties.attrib['BlockYSize'] = str(block_shape[0])
sourceproperties.attrib['BlockXSize'] = str(block_shape[1])
srcrect = ET.SubElement(simplesource, 'SrcRect')
srcrect.attrib['xOff'] = '0'
srcrect.attrib['yOff'] = '0'
srcrect.attrib['xSize'] = str(background.width)
srcrect.attrib['ySize'] = str(background.height)
dstrect = ET.SubElement(simplesource, 'DstRect')
dstrect.attrib['xOff'] = '0'
dstrect.attrib['yOff'] = '0'
dstrect.attrib['xSize'] = str(width)
dstrect.attrib['ySize'] = str(height)
simplesource = ET.SubElement(vrtrasterband, 'SimpleSource')
sourcefilename = ET.SubElement(simplesource, 'SourceFilename')
sourcefilename.attrib['relativeToVRT'] = "0"
sourcefilename.text = vsi_path(parse_path(src_dataset.name))
sourceband = ET.SubElement(simplesource, 'SourceBand')
sourceband.text = str(bidx)
sourceproperties = ET.SubElement(simplesource, 'SourceProperties')
......
affine>=1.3.0
attrs>=16.0.0
boto3>=1.2.4
cligj
enum34
numpy>=1.10
snuggs>=1.4.1
setuptools>=0.9.8
-r requirements.txt
# development specific requirements
cython==0.28.3
delocate
enum34
ghp-import
hypothesis
numpydoc
packaging
......
affine>=1.3.0
attrs>=16.0.0
boto3>=1.2.4
cligj
click==7.0
cligj>=0.5
enum34
numpy>=1.10
snuggs>=1.4.1
......
......@@ -332,7 +332,7 @@ with open('README.rst') as f:
# Runtime requirements.
inst_reqs = [
'affine', 'attrs', 'cligj', 'numpy', 'snuggs>=1.4.1', 'click-plugins']
'affine', 'attrs', 'cligj>=0.5', 'numpy', 'snuggs>=1.4.1', 'click-plugins']
if sys.version_info < (3, 4):
inst_reqs.append('enum34')
......
......@@ -147,7 +147,7 @@ def test_merge_error(test_data_dir_1):
runner = CliRunner()
result = runner.invoke(
main_group, ['merge'] + inputs + [outputname] + ['--nodata', '-1'])
assert result.exit_code == -1
assert result.exit_code
def test_merge_bidx(test_data_dir_3):
......
......@@ -306,7 +306,7 @@ def test_rasterize_invalid_stdin(tmpdir, runner):
result = runner.invoke(
main_group, ['rasterize', output], input='BOGUS')
assert result.exit_code == -1
assert result.exit_code
def test_rasterize_invalid_geojson(tmpdir, runner):
......