Skip to content
Commits on Source (4)
......@@ -36,7 +36,7 @@ Authors
* Martin Kaesberger
* ngrue
* Nat Wilson
* Juan Luis
* Juan Luis Cano
* Gregory Raevski
* Tyler Erickson
* Jeffrey Gerard
......
Changes
=======
1.0.1 (2018-07-23)
------------------
Bug fixes:
- Bounding envelopes are densified at higher precision in transform_bounds to
fix #1411.
- Add LERC compression to enums.Compression (#1412).
- The reproject() function now passes dst_alpha properly to _reproject(), which
unlocks materialization of warp destination alpha band masks (#1417).
- The --dimensions and --src-bounds options of rio-warp can be used together
as expected (#1418).
1.0.0 (2018-07-12)
------------------
......
rasterio (1.0.1-1) unstable; urgency=medium
* Team upload.
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Tue, 24 Jul 2018 07:09:22 +0200
rasterio (1.0.0-1) unstable; urgency=medium
* Team upload.
......
......@@ -648,6 +648,12 @@ Or provide output bounds (in source crs) and resolution:
$ rio warp input.tif output.tif --dst-crs EPSG:4326 --bounds -78 22 -76 24 --res 0.1
Previous command in case of south-up image, ``--`` escapes the next ``-``:
.. code-block:: console
$ rio warp input.tif output.tif --dst-crs EPSG:4326 --bounds -78 22 -76 24 --res 0.1 -- -0.1
Other options are available, see:
.. code-block:: console
......
......@@ -43,7 +43,7 @@ import rasterio.path
__all__ = ['band', 'open', 'pad', 'Env']
__version__ = "1.0.0"
__version__ = "1.0.1"
__gdal_version__ = gdal_version()
# Rasterio attaches NullHandler to the 'rasterio' logger and its
......
......@@ -437,9 +437,6 @@ def _reproject(
else:
dst_bidx = src_bidx
if destination.shape[0] != src_count:
raise ValueError("Destination's shape is invalid")
try:
driver = exc_wrap_pointer(GDALGetDriverByName("MEM"))
except:
......@@ -448,14 +445,22 @@ def _reproject(
"in a `with rasterio.Env()` or `with rasterio.open()` "
"block.")
_, rows, cols = destination.shape
count, rows, cols = destination.shape
datasetname = str(uuid.uuid4()).encode('utf-8')
dst_dataset = exc_wrap_pointer(
GDALCreate(driver, <const char *>datasetname, cols, rows,
src_count,
GDALCreate(driver, <const char *>datasetname, cols, rows, count,
dtypes.dtype_rev[np.dtype(destination.dtype).name], NULL))
if dst_alpha:
for i in range(destination.shape[0]):
try:
delete_nodata_value(GDALGetRasterBand(dst_dataset, i+1))
except NotImplementedError as exc:
log.warn(str(exc))
GDALSetRasterColorInterpretation(GDALGetRasterBand(dst_dataset, dst_alpha), <GDALColorInterp>6)
GDALSetDescription(
dst_dataset, "Temporary destination dataset for _reproject()")
......
......@@ -65,6 +65,7 @@ class Compression(Enum):
lzma = 'LZMA'
none = 'NONE'
zstd = 'ZSTD'
lerc = 'LERC'
class Interleaving(Enum):
......
......@@ -177,9 +177,10 @@ def warp(ctx, files, output, driver, like, dst_crs, dimensions, src_bounds,
# Calculate resolution appropriate for dimensions
# in target.
dst_width, dst_height = dimensions
bounds = src_bounds or src.bounds
try:
xmin, ymin, xmax, ymax = transform_bounds(
src.crs, dst_crs, *src.bounds)
src.crs, dst_crs, *bounds)
except CRSError as err:
raise click.BadParameter(
str(err), param='dst_crs', param_hint='dst_crs')
......
......@@ -154,13 +154,13 @@ def transform_bounds(
for x in (left, right):
in_xs.extend([x] * (densify_pts + 2))
in_ys.extend(
bottom + np.arange(0, densify_pts + 2, dtype=np.float32) *
bottom + np.arange(0, densify_pts + 2, dtype=np.float64) *
((top - bottom) * densify_factor)
)
for y in (bottom, top):
in_xs.extend(
left + np.arange(1, densify_pts + 1, dtype=np.float32) *
left + np.arange(1, densify_pts + 1, dtype=np.float64) *
((right - left) * densify_factor)
)
in_ys.extend([y] * densify_pts)
......@@ -291,7 +291,7 @@ def reproject(source, destination, src_transform=None, gcps=None,
_reproject(
source, destination, src_transform=src_transform, gcps=gcps,
src_crs=src_crs, src_nodata=src_nodata, dst_transform=dst_transform,
dst_crs=dst_crs, dst_nodata=dst_nodata, dst_alpa=dst_alpha,
dst_crs=dst_crs, dst_nodata=dst_nodata, dst_alpha=dst_alpha,
src_alpha=src_alpha, resampling=resampling,
init_dest_nodata=init_dest_nodata, num_threads=num_threads,
warp_mem_limit=warp_mem_limit, **kwargs)
......
......@@ -348,6 +348,26 @@ def test_warp_reproject_src_bounds_res(runner, tmpdir):
assert output.height == 14
def test_warp_reproject_src_bounds_dimensions(runner, tmpdir):
"""--src-bounds option works with dimensions"""
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
out_bounds = [-11850000, 4810000, -11849000, 4812000]
result = runner.invoke(
main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:4326',
'--dimensions', 9, 14, '--src-bounds'] + out_bounds)
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(outputname) as output:
assert output.crs == {'init': 'epsg:4326'}
assert np.allclose(output.bounds[:],
[-106.45036, 39.6138, -106.44136, 39.6278])
assert round(output.transform.a, 4) == 0.001
assert round(-output.transform.e, 4) == 0.001
def test_warp_reproject_dst_bounds(runner, tmpdir):
"""--bounds option works."""
srcname = 'tests/data/shade.tif'
......
......@@ -1247,3 +1247,24 @@ def test_issue1401():
dst_crs=dst_crs,
resampling=Resampling.nearest,
warp_mem_limit=4000)
def test_reproject_dst_alpha(path_rgb_msk_byte_tif):
"""Materialization of external mask succeeds"""
with rasterio.open(path_rgb_msk_byte_tif) as src:
nrows, ncols = src.shape
dst_arr = np.zeros((src.count + 1, nrows, ncols), dtype=np.uint8)
reproject(
rasterio.band(src, src.indexes),
dst_arr,
src_transform=src.transform,
src_crs=src.crs,
dst_transform=DST_TRANSFORM,
dst_crs={'init': 'EPSG:3857'},
dst_alpha=4)
assert dst_arr[3].any()
......@@ -146,3 +146,9 @@ def test_gcps_calculate_transform():
'epsg:3857', 'epsg:4326', width=800, height=800, gcps=src_gcps)
assert width == 1087
assert height == 895
def test_transform_bounds_identity():
"""Confirm fix of #1411"""
bounds = (12978395.906596646, 146759.09430753812, 12983287.876406897, 151651.06411778927)
assert transform_bounds("+init=epsg:3857", "+init=epsg:3857", *bounds) == bounds