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

Bas Couwenberg gitlab at salsa.debian.org
Thu Feb 28 05:59:58 GMT 2019


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


Commits:
10165c86 by Bas Couwenberg at 2019-02-28T05:43:44Z
New upstream version 1.0.20
- - - - -


17 changed files:

- CHANGES.txt
- README.rst
- + docs/faq.rst
- docs/index.rst
- docs/quickstart.rst
- docs/topics/masking-by-shapefile.rst
- docs/topics/migrating-to-v1.rst
- docs/topics/windowed-rw.rst
- rasterio/__init__.py
- rasterio/_base.pyx
- rasterio/_env.pyx
- rasterio/gdal.pxi
- rasterio/merge.py
- rasterio/windows.py
- tests/conftest.py
- tests/test_crs.py
- tests/test_memoryfile.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,13 @@
 Changes
 =======
 
+1.0.20 (2019-02-27)
+-------------------
+
+- Fix for an unchecked NULL pointer introduced in 1.0.19 that could result in
+  segmentation fault on import of rasterio._env on Linux when GDAL data files
+  are not available (for example, with wheels as on PyPI).
+
 1.0.19 (2019-02-26)
 -------------------
 


=====================================
README.rst
=====================================
@@ -195,7 +195,7 @@ Linux
 Rasterio distributions are available from UbuntuGIS and Anaconda's conda-forge
 channel.
 
-`Manylinux1 <https://github.com/pypa/manylinux>`__ wheels are available on PyPI.```
+`Manylinux1 <https://github.com/pypa/manylinux>`__ wheels are available on PyPI.
 
 OS X
 ++++


=====================================
docs/faq.rst
=====================================
@@ -0,0 +1,46 @@
+Frequently Asked Questions
+==========================
+
+Where is "ERROR 4: Unable to open EPSG support file gcs.csv" coming from and what does it mean?
+-----------------------------------------------------------------------------------------------
+
+The full message is "ERROR 4: Unable to open EPSG support file gcs.csv.  Try
+setting the GDAL_DATA environment variable to point to the directory containing
+EPSG csv files." The GDAL/OGR library prints this text to your process's stdout
+stream when it can not find the gcs.csv data file it needs to interpret spatial
+reference system information stored with a dataset. If you've never seen this
+before, you can summon this message by setting GDAL_DATA to a bogus value in
+your shell and running a command like ogrinfo:
+
+.. code-block:: console
+
+    $ GDAL_DATA="/path/to/nowhere" ogrinfo example.shp -so example
+    INFO: Open of 'example.shp'
+          using driver 'ESRI Shapefile' successful.
+
+    Layer name: example
+    Geometry: Polygon
+    Feature Count: 67
+    Extent: (-113.564247, 37.068981) - (-104.970871, 41.996277)
+    ERROR 4: Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
+
+If you're using GDAL software installed by a package management system like apt
+or yum, or Homebrew, or if you've built and installed it using ``configure;
+make; make install``, you don't need to set the GDAL_DATA environment variable.
+That software has the right directory path built in. If you see this error,
+it's likely a sign that GDAL_DATA is set to a bogus value. Unset GDAL_DATA if
+it exists and see if that eliminates the error condition and the message.
+
+If you're installing GDAL into a Conda environment or into a Python virtual
+environment (remember that the Rasterio wheels on the Python Package Index
+include a GDAL library and its data files) the situation is different. The
+proper data directory path is not built in and GDAL_DATA must be set.
+
+Rasterio 1.0.18, whether from PyPI or Conda, will set the GDAL_DATA environment
+variable to the correct location when it is imported, but only if it has not
+already been set. Previous versions of Rasterio tried to avoid patching the
+environment of the process, but there's really no better option.
+
+Get the latest version of Rasterio, 1.0.18, and use it without setting
+GDAL_DATA. You shouldn't experience the error condition or the message about
+it.


=====================================
docs/index.rst
=====================================
@@ -51,6 +51,7 @@ Rasterio supports Python versions 2.7 and 3.3 or higher.
    topics/index
    api/index
    contributing
+   faq
 
 Indices and Tables
 ==================


=====================================
docs/quickstart.rst
=====================================
@@ -194,7 +194,7 @@ dataset's upper left corner, do the following.
     >>> row, col = dataset.index(x, y)
     >>> row, col
     (1666, 3333)
-    >>> band_one[row, col]
+    >>> band1[row, col]
     7566
 
 To get the spatial coordinates of a pixel, use the dataset's ``xy()`` method.


=====================================
docs/topics/masking-by-shapefile.rst
=====================================
@@ -9,16 +9,15 @@ Using ``rasterio`` with ``fiona``, it is simple to open a shapefile, read geomet
         import rasterio.mask
 
         with fiona.open("tests/data/box.shp", "r") as shapefile:
-            features = [feature["geometry"] for feature in shapefile] 
+            shapes = [feature["geometry"] for feature in shapefile] 
 
 This shapefile contains a single polygon, a box near the center of the raster, so in this case, our list of features is one element long.
 
 .. code-block:: python
 
         with rasterio.open("tests/data/RGB.byte.tif") as src:
-            out_image, out_transform = rasterio.mask.mask(src, features,
-                                                                crop=True)
-            out_meta = src.meta.copy()
+            out_image, out_transform = rasterio.mask.mask(src, shapes, crop=True)
+            out_meta = src.meta
 
 Using ``plot`` and ``imshow`` from ``matplotlib``, we can see the region defined by the shapefile in red overlaid on the original raster.
 
@@ -32,6 +31,7 @@ Applying the features in the shapefile as a mask on the raster sets all pixels o
                          "height": out_image.shape[1],
                          "width": out_image.shape[2],
                          "transform": out_transform})
+
         with rasterio.open("RGB.byte.masked.tif", "w", **out_meta) as dest:
             dest.write(out_image) 
 


=====================================
docs/topics/migrating-to-v1.rst
=====================================
@@ -171,7 +171,7 @@ Tickets
 ```````
 
 * `#284 <https://github.com/mapbox/rasterio/pull/284>`__ - Deprecation of
-  ``src.read_masks()``.
+  ``src.read_mask()``.
 
 
 Moved: Functions for working with dataset windows
@@ -263,4 +263,4 @@ Creation Options
 
 Rasterio no longer saves dataset creation options to the metadata of created
 datasets and will ignore such metadata starting in version 1.0. Users may opt
-in to this by setting RIO_IGNORE_CREATION_KWDS=TRUE in their environments.
\ No newline at end of file
+in to this by setting RIO_IGNORE_CREATION_KWDS=TRUE in their environments.


=====================================
docs/topics/windowed-rw.rst
=====================================
@@ -37,7 +37,6 @@ and open-ended slices may be used.
    Window.from_slices(slice(10, -10), slice(10, -10), height=100, width=100)
    # Window(col_off=10, row_off=10, width=80, height=80)
 
-
 Reading
 -------
 
@@ -115,7 +114,7 @@ a dataset:
     from rasterio.windows import get_data_window
 
     with rasterio.open('tests/data/RGB.byte.tif') as src:
-        window - get_data_window(src.read(1, masked-True))
+        window = get_data_window(src.read(1, masked=True))
         # window = Window(col_off=13, row_off=3, width=757, height=711)
 
         kwargs = src.meta.copy()
@@ -127,6 +126,29 @@ a dataset:
         with rasterio.open('/tmp/cropped.tif', 'w', **kwargs) as dst:
             dst.write(src.read(window=window))
 
+Window transforms
+-----------------
+
+The affine transform of a window can be accessed using a dataset's
+``window_transform`` method:
+
+.. code-block:: pycon
+
+    >>> import rasterio
+    >>> from rasterio.windows import Window
+    >>> win = Window(256, 256, 128, 128)
+    >>> with rasterio.open('tests/data/RGB.byte.tif') as src:
+    ...     src_transform = src.transform
+    ...     win_transform = src.window_transform(win)
+    ...
+    >>> print(src_transform)
+    | 300.04, 0.00, 101985.00|
+    | 0.00,-300.04, 2826915.00|
+    | 0.00, 0.00, 1.00|
+    >>> print(win_transform)
+    | 300.04, 0.00, 178794.71|
+    | 0.00,-300.04, 2750104.30|
+    | 0.00, 0.00, 1.00|
 
 Window utilities
 ----------------


=====================================
rasterio/__init__.py
=====================================
@@ -42,7 +42,7 @@ import rasterio.path
 
 
 __all__ = ['band', 'open', 'pad', 'Env']
-__version__ = "1.0.19"
+__version__ = "1.0.20"
 __gdal_version__ = gdal_version()
 
 # Rasterio attaches NullHandler to the 'rasterio' logger and its


=====================================
rasterio/_base.pyx
=====================================
@@ -1099,7 +1099,7 @@ cdef class DatasetBase(object):
             if color == NULL:
                 log.warn("NULL color at %d, skipping", i)
                 continue
-            log.info(
+            log.debug(
                 "Color: (%d, %d, %d, %d)",
                 color.c1, color.c2, color.c3, color.c4)
             retval[i] = (color.c1, color.c2, color.c3, color.c4)


=====================================
rasterio/_env.pyx
=====================================
@@ -209,8 +209,14 @@ class GDALDataFinder(object):
         str (on success) or None (on failure)
 
         """
-        path = CPLFindFile("gdal", basename.encode('utf-8'))
-        return path
+        cdef const char *path_c = NULL
+        basename_b = basename.encode('utf-8')
+        path_c = CPLFindFile("gdal", <const char *>basename_b)
+        if path_c == NULL:
+            return None
+        else:
+            path = path_c
+            return path
 
     def search(self, prefix=None):
         """Returns GDAL data directory


=====================================
rasterio/gdal.pxi
=====================================
@@ -91,7 +91,6 @@ cdef extern from "ogr_srs_api.h" nogil:
     OGRSpatialReferenceH OSRClone(OGRSpatialReferenceH srs)
     int OSRExportToProj4(OGRSpatialReferenceH srs, char **params)
     int OSRExportToWkt(OGRSpatialReferenceH srs, char **params)
-    int OSRFixup(OGRSpatialReferenceH srs)
     const char *OSRGetAuthorityName(OGRSpatialReferenceH srs, const char *key)
     const char *OSRGetAuthorityCode(OGRSpatialReferenceH srs, const char *key)
     int OSRImportFromEPSG(OGRSpatialReferenceH srs, int code)


=====================================
rasterio/merge.py
=====================================
@@ -43,6 +43,8 @@ def merge(datasets, bounds=None, res=None, nodata=None, precision=7, indexes=Non
     nodata: float, optional
         nodata value to use in output file. If not set, uses the nodata value
         in the first input raster.
+    precision: float, optional
+        Number of decimal points of precision when computing inverse transform.
     indexes : list of ints or a single int, optional
         bands to read and merge
 


=====================================
rasterio/windows.py
=====================================
@@ -639,8 +639,8 @@ class Window(object):
     def round_lengths(self, op='floor', pixel_precision=None):
         """Return a copy with width and height rounded.
 
-        Lengths are rounded to the nearest whole number. The offsets
-        are not changed.
+        Lengths are rounded to the preceding (floor) or succeeding (ceil)
+        whole number. The offsets are not changed.
 
         Parameters
         ----------
@@ -669,8 +669,8 @@ class Window(object):
     def round_offsets(self, op='floor', pixel_precision=None):
         """Return a copy with column and row offsets rounded.
 
-        Offsets are rounded to the nearest whole number. The lengths
-        are not changed.
+        Offsets are rounded to the preceding (floor) or succeeding (ceil)
+        whole number. The lengths are not changed.
 
         Parameters
         ----------


=====================================
tests/conftest.py
=====================================
@@ -475,16 +475,19 @@ def data_dir():
 
 @pytest.fixture(scope='session')
 def path_rgb_byte_tif(data_dir):
+    """The original RGB test fixture with no sidecar files"""
     return os.path.join(data_dir, 'RGB.byte.tif')
 
 
 @pytest.fixture(scope='session')
 def path_rgba_byte_tif(data_dir):
+    """Derived from RGB.byte.tif, this has an alpha band"""
     return os.path.join(data_dir, 'RGBA.byte.tif')
 
 
 @pytest.fixture(scope='session')
 def path_rgb_msk_byte_tif(data_dir):
+    """Derived from RGB.byte.tif, this has an external mask"""
     return os.path.join(data_dir, 'RGB2.byte.tif')
 
 


=====================================
tests/test_crs.py
=====================================
@@ -154,7 +154,7 @@ def test_from_string():
     assert wgs84_crs.to_dict() == {'init': 'epsg:4326'}
 
     # Make sure this doesn't get handled using the from_epsg() even though 'epsg' is in the string
-    epsg_init_crs = CRS.from_string('+units=m +init=epsg:26911 +no_defs=True')
+    epsg_init_crs = CRS.from_string('+init=epsg:26911')
     assert epsg_init_crs.to_dict() == {'init': 'epsg:26911'}
 
 
@@ -184,6 +184,18 @@ def test_is_projected():
     assert CRS(wgs84_crs).is_projected is False
 
 
+ at requires_gdal21(reason="CRS equality is buggy pre-2.1")
+ at pytest.mark.parametrize('epsg_code', [3857, 4326, 26913, 32618])
+def test_equality_from_epsg(epsg_code):
+    assert CRS.from_epsg(epsg_code) == CRS.from_epsg(epsg_code)
+
+
+ at requires_gdal21(reason="CRS equality is buggy pre-2.1")
+ at pytest.mark.parametrize('epsg_code', [3857, 4326, 26913, 32618])
+def test_equality_from_dict(epsg_code):
+    assert CRS.from_dict(init='epsg:{}'.format(epsg_code)) == CRS.from_dict(init='epsg:{}'.format(epsg_code))
+
+
 def test_is_same_crs():
     crs1 = CRS({'init': 'epsg:4326'})
     crs2 = CRS({'init': 'epsg:3857'})


=====================================
tests/test_memoryfile.py
=====================================
@@ -11,7 +11,9 @@ import pytest
 
 import rasterio
 from rasterio.io import MemoryFile, ZipMemoryFile
+from rasterio.enums import MaskFlags
 from rasterio.env import GDALVersion
+from rasterio.shutil import copyfiles
 
 
 # Skip ENTIRE module if not GDAL >= 2.x.
@@ -256,3 +258,26 @@ def test_write_plus_model_jpeg():
             assert (data[0] == 255).all()
             assert (data[1] == 204).all()
             assert (data[2] == 153).all()
+
+
+def test_memfile_copyfiles(path_rgb_msk_byte_tif):
+    """Multiple files can be copied to a MemoryFile using copyfiles"""
+    with rasterio.open(path_rgb_msk_byte_tif) as src:
+        src_basename = os.path.basename(src.name)
+        with MemoryFile(filename=src_basename) as memfile:
+            copyfiles(src.name, memfile.name)
+            with memfile.open() as rgb2:
+                assert sorted(rgb2.files) == sorted(['/vsimem/{}'.format(src_basename), '/vsimem/{}.msk'.format(src_basename)])
+
+
+def test_multi_memfile(path_rgb_msk_byte_tif):
+    """Multiple files can be copied to a MemoryFile using copyfiles"""
+    with open(path_rgb_msk_byte_tif, 'rb') as tif_fp:
+        tif_bytes = tif_fp.read()
+    with open(path_rgb_msk_byte_tif + '.msk', 'rb') as msk_fp:
+        msk_bytes = msk_fp.read()
+
+    with MemoryFile(tif_bytes, filename='foo.tif') as tifmemfile, MemoryFile(msk_bytes, filename='foo.tif.msk') as mskmemfile:
+        with tifmemfile.open() as src:
+            assert sorted(src.files) == sorted(['/vsimem/foo.tif', '/vsimem/foo.tif.msk'])
+            assert src.mask_flag_enums == ([MaskFlags.per_dataset],) * 3



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

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/rasterio/commit/10165c86fd5a38c041a2ffaf0aae0fb572dade1c
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/20190228/91a3574e/attachment-0001.html>


More information about the Pkg-grass-devel mailing list