1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
|
"""Unittests for $ rio warp"""
import os
import affine
import numpy as np
import pytest
import rasterio
from rasterio.warp import SUPPORTED_RESAMPLING
from rasterio.rio import warp
from rasterio.rio.main import main_group
def test_dst_crs_error(runner, tmpdir):
"""Invalid JSON is a bad parameter."""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', '{foo: bar}'])
assert result.exit_code == 2
assert 'for dst_crs: CRS appears to be JSON but is not' in result.output
def test_dst_crs_error_2(runner, tmpdir):
"""Invalid PROJ.4 is a bad parameter."""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', '{"proj": "foobar"}'])
assert result.exit_code == 2
assert 'Invalid value for dst_crs' in result.output
def test_dst_crs_error_epsg(runner, tmpdir):
"""Malformed EPSG string is a bad parameter."""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:'])
assert result.exit_code == 2
assert "for dst_crs: Invalid CRS:" in result.output
def test_dst_crs_error_epsg_2(runner, tmpdir):
"""Invalid EPSG code is a bad parameter."""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:0'])
assert result.exit_code == 2
assert 'for dst_crs: EPSG codes are positive integers' in result.output
def test_dst_nodata_float_no_src_nodata_err(runner, tmpdir):
"""Valid integer destination nodata dtype"""
srcname = 'tests/data/float.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-nodata', '0.0'])
assert result.exit_code == 2
assert 'src-nodata must be provided because dst-nodata is not None' in result.output
def test_src_nodata_int_ok(runner, tmpdir):
"""Check if input nodata is overridden"""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--src-nodata', '1'])
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert src.meta['nodata'] == 1
def test_dst_nodata_int_ok(runner, tmpdir):
"""Check if input nodata is overridden"""
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-nodata', '255'])
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert src.meta['nodata'] == 255
def test_src_nodata_float_ok(runner, tmpdir):
"""Check if input nodata is overridden"""
srcname = 'tests/data/float.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--src-nodata', '1.5'])
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert src.meta['nodata'] == 1.5
def test_dst_nodata_float_override_src_ok(runner, tmpdir):
"""Check if srcnodata is overridden"""
srcname = 'tests/data/float.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--src-nodata', '1.5', '--dst-nodata', '2.5'])
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert src.meta['nodata'] == 2.5
def test_warp_no_reproject(runner, tmpdir):
""" When called without parameters, output should be same as source """
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, ['warp', srcname, outputname])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.count == src.count
assert output.crs == src.crs
assert output.nodata == src.nodata
assert np.allclose(output.bounds, src.bounds)
assert output.transform.almost_equals(src.transform)
assert np.allclose(output.read(1), src.read(1))
def test_warp_no_reproject_dimensions(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dimensions', '100', '100'])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.crs == src.crs
assert output.width == 100
assert output.height == 100
assert np.allclose([97.839396, 97.839396],
[output.transform.a, -output.transform.e])
def test_warp_no_reproject_res(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--res', 30])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.crs == src.crs
assert np.allclose([30, 30], [output.transform.a, -output.transform.e])
assert output.width == 326
assert output.height == 326
def test_warp_no_reproject_bounds(runner, tmpdir):
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, '--bounds'] + out_bounds)
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.crs == src.crs
assert np.allclose(output.bounds, out_bounds)
assert np.allclose([src.transform.a, src.transform.e],
[output.transform.a, output.transform.e])
assert output.width == 105
assert output.height == 209
def test_warp_no_reproject_bounds_res(runner, tmpdir):
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, '--res', 30, '--bounds'] + out_bounds)
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.crs == src.crs
assert np.allclose(output.bounds, out_bounds)
assert np.allclose([30, 30], [output.transform.a, -output.transform.e])
assert output.width == 33
assert output.height == 67
# dst-bounds should be an alias to bounds
outputname = str(tmpdir.join('test2.tif'))
out_bounds = [-11850000, 4810000, -11849000, 4812000]
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--res', 30, '--dst-bounds'] + out_bounds)
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert np.allclose(output.bounds, out_bounds)
def test_warp_no_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, '--dimensions', 9, 14,
'--src-bounds'] + out_bounds)
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.crs == src.crs
assert np.allclose(output.bounds, out_bounds)
assert np.allclose([111.111111, 142.857142],
[output.transform.a, -output.transform.e])
assert output.width == 9
assert output.height == 14
def test_warp_reproject_dst_crs(runner, tmpdir):
srcname = 'tests/data/RGB.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:4326'])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(srcname) as src:
with rasterio.open(outputname) as output:
assert output.count == src.count
assert output.crs == {'init': 'epsg:4326'}
assert output.width == 835
assert output.height == 696
assert np.allclose(output.bounds, [
-78.95864996545055, 23.564787976164418,
-76.5759177302349, 25.550873767433984])
def test_warp_reproject_dst_crs_proj4(runner, tmpdir):
proj4 = '+proj=longlat +ellps=WGS84 +datum=WGS84'
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', proj4])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(outputname) as output:
assert output.crs == {'init': 'epsg:4326'} # rasterio converts to EPSG
def test_warp_reproject_res(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:4326', '--res', 0.01])
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([0.01, 0.01], [output.transform.a, -output.transform.e])
assert output.width == 9
assert output.height == 7
def test_warp_reproject_dimensions(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:4326',
'--dimensions', '100', '100'])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(outputname) as output:
assert output.crs == {'init': 'epsg:4326'}
assert output.width == 100
assert output.height == 100
assert np.allclose([0.0008789062498762235, 0.0006771676143921468],
[output.transform.a, -output.transform.e])
def test_warp_reproject_dimensions_invalid_params(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
bad_params = [
['--bounds', '0', '0', '10', '10'],
['--res', '10']
]
for param in bad_params:
result = runner.invoke(warp.warp,
[srcname, outputname, '--dst-crs', 'EPSG:4326',
'--dimensions', '100', '100'] +
param)
assert result.exit_code == 2
assert '--dimensions cannot be used with' in result.output
def test_warp_reproject_bounds_no_res(runner, tmpdir):
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', '--bounds'] +
out_bounds)
assert result.exit_code == 2
def test_warp_reproject_multi_bounds_fail(runner, tmpdir):
"""Mixing --bounds and --src-bounds fails."""
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',
'--src-bounds'] + out_bounds + ['--bounds'] + out_bounds)
assert result.exit_code == 2
def test_warp_reproject_bounds_crossup_fail(runner, tmpdir):
"""Crossed-up bounds raises RasterioIOError."""
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",
"--res",
0.001,
"--bounds",
]
+ out_bounds,
)
assert result.exit_code == 1
def test_warp_reproject_src_bounds_res(runner, tmpdir):
"""--src-bounds option works."""
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',
'--res', 0.001, '--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 np.allclose([0.001, 0.001],
[output.transform.a, -output.transform.e])
assert output.width == 9
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'
outputname = str(tmpdir.join('test.tif'))
out_bounds = [-106.45036, 39.6138, -106.44136, 39.6278]
result = runner.invoke(
main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:4326',
'--res', 0.001, '--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[0::3],
[-106.45036, 39.6278])
assert np.allclose([0.001, 0.001],
[output.transform.a, -output.transform.e])
# XXX: an extra row and column is produced in the dataset
# because we're using ceil instead of floor internally.
# Not necessarily a bug, but may change in the future.
assert np.allclose([output.bounds[2] - 0.001, output.bounds[1] + 0.001],
[-106.44136, 39.6138])
assert output.width == 10
assert output.height == 15
def test_warp_reproject_like(runner, tmpdir):
likename = str(tmpdir.join('like.tif'))
kwargs = {
"crs": {'init': 'epsg:4326'},
"transform": affine.Affine(0.001, 0, -106.523,
0, -0.001, 39.6395),
"count": 1,
"dtype": rasterio.uint8,
"driver": "GTiff",
"width": 10,
"height": 10,
"nodata": 0
}
with rasterio.open(likename, 'w', **kwargs) as dst:
data = np.zeros((10, 10), dtype=rasterio.uint8)
dst.write(data, indexes=1)
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--like', likename])
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(
[0.001, 0.001], [output.transform.a, -output.transform.e])
assert output.width == 10
assert output.height == 10
def test_warp_reproject_like_invalid_params(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
bad_params = [
['--dimensions', '10', '10'],
['--dst-crs', 'EPSG:4326'],
['--bounds', '0', '0', '10', '10'],
['--res', '10']
]
for param in bad_params:
result = runner.invoke(warp.warp,
[srcname, outputname, '--like', srcname] +
param)
assert result.exit_code == 2
assert '--like cannot be used with any of' in result.output
def test_warp_reproject_nolostdata(runner, tmpdir):
srcname = 'tests/data/world.byte.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:3857'])
assert result.exit_code == 0
assert os.path.exists(outputname)
with rasterio.open(outputname) as output:
arr = output.read()
# 50 column swath on the right edge should have some ones (gdalwarped has 7223)
assert arr[0, :, -50:].sum() > 7000
assert output.crs.to_epsg() == 3857
def test_warp_dst_crs_empty_string(runner, tmpdir):
"""`$ rio warp --dst-crs ''` used to perform a falsey check that would treat
`--dst-crs ''` as though `--dst-crs` was not supplied at all. If the user
gives any value we should let `rasterio.crs.from_string()` handle the
validation.
"""
infile = 'tests/data/RGB.byte.tif'
outfile = str(tmpdir.mkdir('empty_warp_dst_crs.tif').join('test.tif'))
result = runner.invoke(main_group, [
'warp', infile, outfile, '--dst-crs', ''])
assert result.exit_code != 0
assert 'empty or invalid' in result.output
def test_warp_badcrs_dimensions(runner, tmpdir):
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', '{"init": "epsg:-1"}',
'--dimensions', '100', '100'])
assert result.exit_code == 2
assert "Invalid value for dst_crs" in result.output
def test_warp_badcrs_src_bounds(runner, tmpdir):
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', '{"init": "epsg:-1"}',
'--res', 0.001, '--src-bounds'] + out_bounds)
assert result.exit_code == 2
assert "Invalid value for dst_crs" in result.output
def test_warp_reproject_check_invert_true(runner, tmpdir):
outputname = str(tmpdir.join('test.tif'))
output2name = str(tmpdir.join('test2.tif'))
srcname = 'tests/data/world.rgb.tif'
# default True
runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'EPSG:3759'])
# explicit True
runner.invoke(main_group, [
'warp', srcname, output2name, '--check-invert-proj',
'--dst-crs', 'EPSG:3759'])
with rasterio.open(outputname) as output, rasterio.open(output2name) as output2:
assert output.shape == output2.shape
def test_warp_vrt_gcps(runner, tmpdir):
"""A VRT with GCPs can be warped."""
srcname = 'tests/data/white-gemini-iv.vrt'
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', srcname, outputname, '--dst-crs', 'epsg:32618'])
assert result.exit_code == 0
# All 4 corners have no data.
with rasterio.open(outputname) as src:
data = src.read()
assert not data[:, 0, 0].any()
assert not data[:, 0, -1].any()
assert not data[:, -1, -1].any()
assert not data[:, -1, 0].any()
@pytest.mark.parametrize("method", SUPPORTED_RESAMPLING)
def test_warp_resampling(runner, path_rgb_byte_tif, tmpdir, method):
"""Resampling methods supported by this version of GDAL should run
successfully"""
outputname = str(tmpdir.join('test.tif'))
result = runner.invoke(main_group, [
'warp', path_rgb_byte_tif, outputname,
'--dst-crs', 'epsg:3857',
'--resampling', method.name])
print(result.output)
assert result.exit_code == 0
def test_unrotate(runner, tmp_path):
"""rio-warp unrotates imagery by default, like gdalwarp"""
outputname = os.fspath(tmp_path.joinpath("test.tif"))
runner.invoke(main_group, ["warp", "tests/data/rotated.tif", outputname])
# There is no skew in the output.
with rasterio.open(outputname) as src:
assert src.transform.b == 0.0
assert src.transform.d == 0.0
@pytest.mark.parametrize(
"wotopt", ["--to", "--transformer-option", "--wo", "--warper-option"]
)
def test_coordinate_operation(runner, tmp_path, wotopt):
"""Verify that transformer coordinate operations are activated."""
outputname = os.fspath(tmp_path.joinpath("test.tif"))
pipeline = "+proj=pipeline step inv proj=utm zone=11 ellps=clrk66 step proj=unitconvert xy_in=rad xy_out=deg step proj=axisswap order=2,1"
result = runner.invoke(
main_group,
[
"warp",
"--dst-crs",
"EPSG:4326",
"--resampling",
"cubic",
wotopt,
f"coordinate_operation={pipeline}",
"tests/data/byte.tif",
outputname,
],
)
assert result.exit_code == 0
with rasterio.open(outputname) as src:
assert src.checksum(1) == 4705
def test_dry_run(runner, tmpdir):
# See also warp_reproject_bounds_crossup_fail.
srcname = 'tests/data/shade.tif'
outputname = str(tmpdir.join('test.tif'))
out_bounds = [-11850000, 4810000, -11849000, 4812000]
result = runner.invoke(
main_group,
[
"warp",
"--dry-run",
srcname,
outputname,
"--dst-crs",
"EPSG:4326",
"--res",
0.001,
"--bounds",
]
+ out_bounds,
)
assert result.exit_code == 0
assert '"width": 1000000' in result.output
assert '"height": 2000000' in result.output
|