@@ -338,6 +338,46 @@ def test_gdalalg_raster_calc_error_extent_mismatch(calc, tmp_vsimem):
338
338
assert src .GetGeoTransform () == dst .GetGeoTransform ()
339
339
340
340
341
+ def test_gdalalg_raster_calc_error_extent_within_tolerance (calc , tmp_vsimem ):
342
+
343
+ input_1 = tmp_vsimem / "in1.tif"
344
+ input_2 = tmp_vsimem / "in2.tif"
345
+ outfile = tmp_vsimem / "out.tif"
346
+
347
+ with gdal .GetDriverByName ("GTIff" ).Create (input_2 , 3600 , 3600 ) as ds :
348
+ ds .SetGeoTransform (
349
+ (
350
+ 2.4999861111111112e01 ,
351
+ 2.7777777777777778e-04 ,
352
+ 0.0000000000000000e00 ,
353
+ 8.0000138888888884e01 ,
354
+ 0.0000000000000000e00 ,
355
+ - 2.7777777777777778e-04 ,
356
+ )
357
+ )
358
+ with gdal .GetDriverByName ("GTiff" ).Create (input_1 , 3600 , 3600 ) as ds :
359
+ # this geotransform represents error introduced by writing a dataset with the above
360
+ # geotransform to netCDF
361
+ ds .SetGeoTransform (
362
+ (
363
+ 2.4999861111111112e01 ,
364
+ 2.7777777777777778e-04 ,
365
+ 0.0000000000000000e00 ,
366
+ 8.0000138888888884e01 ,
367
+ 0.0000000000000000e00 ,
368
+ - 2.7777777777778173e-04 ,
369
+ )
370
+ )
371
+
372
+ calc ["input" ] = [f"A={ input_1 } " , f"B={ input_2 } " ]
373
+ calc ["output" ] = outfile
374
+ calc ["calc" ] = ["A+B" ]
375
+ assert calc .Run ()
376
+
377
+ with gdal .Open (input_1 ) as src , gdal .Open (outfile ) as dst :
378
+ assert src .GetGeoTransform () == dst .GetGeoTransform ()
379
+
380
+
341
381
def test_gdalalg_raster_calc_error_crs_mismatch (calc , tmp_vsimem ):
342
382
343
383
input_1 = tmp_vsimem / "in1.tif"
0 commit comments