[Git][debian-gis-team/rasterio][upstream] New upstream version 1.0.7

Bas Couwenberg gitlab at salsa.debian.org
Thu Sep 27 07:12:06 BST 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / rasterio


Commits:
0916bd36 by Bas Couwenberg at 2018-09-27T05:06:39Z
New upstream version 1.0.7
- - - - -


16 changed files:

- CHANGES.txt
- rasterio/__init__.py
- rasterio/_io.pxd
- rasterio/_io.pyx
- rasterio/rio/convert.py
- rasterio/rio/info.py
- rasterio/rio/rasterize.py
- rasterio/rio/rm.py
- rasterio/rio/shapes.py
- rasterio/rio/warp.py
- rasterio/vrt.py
- requirements-dev.txt
- requirements.txt
- setup.py
- tests/test_rio_merge.py
- tests/test_rio_rasterize.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,19 @@
 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/__init__.py
=====================================
@@ -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


=====================================
rasterio/_io.pxd
=====================================
@@ -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
 
 


=====================================
rasterio/_io.pyx
=====================================
@@ -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:]


=====================================
rasterio/rio/convert.py
=====================================
@@ -11,12 +11,7 @@ from rasterio.rio.helpers import resolve_inout
 
 
 @click.command(short_help="Copy and convert raster dataset.")
- at click.argument(
-    'files',
-    nargs=-1,
-    type=click.Path(resolve_path=True),
-    required=True,
-    metavar="INPUT OUTPUT")
+ at options.files_inout_arg
 @options.output_opt
 @format_opt
 @options.dtype_opt


=====================================
rasterio/rio/info.py
=====================================
@@ -52,7 +52,7 @@ from rasterio.rio import options
                    "(use --bidx).")
 @click.option('--subdatasets', 'meta_member', flag_value='subdatasets',
               help="Print subdataset identifiers.")
- at click.option('-v', '--tell-me-more', '--verbose', is_flag=True,
+ at click.option('-v', '--tell-me-more', '--verbose', 'verbose', is_flag=True,
               help="Output extra information.")
 @options.bidx_opt
 @options.masked_opt


=====================================
rasterio/rio/rasterize.py
=====================================
@@ -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)
 


=====================================
rasterio/rio/rm.py
=====================================
@@ -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):


=====================================
rasterio/rio/shapes.py
=====================================
@@ -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


=====================================
rasterio/rio/warp.py
=====================================
@@ -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',


=====================================
rasterio/vrt.py
=====================================
@@ -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()
 
-        simplesource = ET.SubElement(vrtrasterband, 'SimpleSource')
+        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')


=====================================
requirements-dev.txt
=====================================
@@ -1,17 +1,8 @@
-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


=====================================
requirements.txt
=====================================
@@ -1,7 +1,8 @@
 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


=====================================
setup.py
=====================================
@@ -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')


=====================================
tests/test_rio_merge.py
=====================================
@@ -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):


=====================================
tests/test_rio_rasterize.py
=====================================
@@ -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):



View it on GitLab: https://salsa.debian.org/debian-gis-team/rasterio/commit/0916bd363f40e08d41ff390d240f6c0d8d5c3d03

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/rasterio/commit/0916bd363f40e08d41ff390d240f6c0d8d5c3d03
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20180927/6eb6c713/attachment-0001.html>


More information about the Pkg-grass-devel mailing list