@@ -4215,15 +4215,15 @@ class TestRasterio:
4215
4215
def test_serialization (self ):
4216
4216
with create_tmp_geotiff (additional_attrs = {}) as (tmp_file , expected ):
4217
4217
# Write it to a netcdf and read again (roundtrip)
4218
- with xr .open_rasterio (tmp_file ) as rioda :
4218
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4219
4219
with create_tmp_file (suffix = ".nc" ) as tmp_nc_file :
4220
4220
rioda .to_netcdf (tmp_nc_file )
4221
4221
with xr .open_dataarray (tmp_nc_file ) as ncds :
4222
4222
assert_identical (rioda , ncds )
4223
4223
4224
4224
def test_utm (self ):
4225
4225
with create_tmp_geotiff () as (tmp_file , expected ):
4226
- with xr .open_rasterio (tmp_file ) as rioda :
4226
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4227
4227
assert_allclose (rioda , expected )
4228
4228
assert rioda .attrs ["scales" ] == (1.0 , 1.0 , 1.0 )
4229
4229
assert rioda .attrs ["offsets" ] == (0.0 , 0.0 , 0.0 )
@@ -4239,7 +4239,9 @@ def test_utm(self):
4239
4239
)
4240
4240
4241
4241
# Check no parse coords
4242
- with xr .open_rasterio (tmp_file , parse_coordinates = False ) as rioda :
4242
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4243
+ tmp_file , parse_coordinates = False
4244
+ ) as rioda :
4243
4245
assert "x" not in rioda .coords
4244
4246
assert "y" not in rioda .coords
4245
4247
@@ -4251,7 +4253,7 @@ def test_non_rectilinear(self):
4251
4253
transform = from_origin (0 , 3 , 1 , 1 ).rotation (45 ), crs = None
4252
4254
) as (tmp_file , _ ):
4253
4255
# Default is to not parse coords
4254
- with xr .open_rasterio (tmp_file ) as rioda :
4256
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4255
4257
assert "x" not in rioda .coords
4256
4258
assert "y" not in rioda .coords
4257
4259
assert "crs" not in rioda .attrs
@@ -4266,7 +4268,9 @@ def test_non_rectilinear(self):
4266
4268
4267
4269
# See if a warning is raised if we force it
4268
4270
with pytest .warns (Warning , match = "transformation isn't rectilinear" ):
4269
- with xr .open_rasterio (tmp_file , parse_coordinates = True ) as rioda :
4271
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4272
+ tmp_file , parse_coordinates = True
4273
+ ) as rioda :
4270
4274
assert "x" not in rioda .coords
4271
4275
assert "y" not in rioda .coords
4272
4276
@@ -4279,7 +4283,7 @@ def test_platecarree(self):
4279
4283
crs = "+proj=latlong" ,
4280
4284
open_kwargs = {"nodata" : - 9765 },
4281
4285
) as (tmp_file , expected ):
4282
- with xr .open_rasterio (tmp_file ) as rioda :
4286
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4283
4287
assert_allclose (rioda , expected )
4284
4288
assert rioda .attrs ["scales" ] == (1.0 ,)
4285
4289
assert rioda .attrs ["offsets" ] == (0.0 ,)
@@ -4327,7 +4331,7 @@ def test_notransform(self):
4327
4331
"x" : [0.5 , 1.5 , 2.5 , 3.5 ],
4328
4332
},
4329
4333
)
4330
- with xr .open_rasterio (tmp_file ) as rioda :
4334
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4331
4335
assert_allclose (rioda , expected )
4332
4336
assert rioda .attrs ["scales" ] == (1.0 , 1.0 , 1.0 )
4333
4337
assert rioda .attrs ["offsets" ] == (0.0 , 0.0 , 0.0 )
@@ -4342,7 +4346,9 @@ def test_indexing(self):
4342
4346
with create_tmp_geotiff (
4343
4347
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4344
4348
) as (tmp_file , expected ):
4345
- with xr .open_rasterio (tmp_file , cache = False ) as actual :
4349
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4350
+ tmp_file , cache = False
4351
+ ) as actual :
4346
4352
4347
4353
# tests
4348
4354
# assert_allclose checks all data + coordinates
@@ -4458,7 +4464,7 @@ def test_caching(self):
4458
4464
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4459
4465
) as (tmp_file , expected ):
4460
4466
# Cache is the default
4461
- with xr .open_rasterio (tmp_file ) as actual :
4467
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as actual :
4462
4468
4463
4469
# This should cache everything
4464
4470
assert_allclose (actual , expected )
@@ -4474,7 +4480,9 @@ def test_chunks(self):
4474
4480
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4475
4481
) as (tmp_file , expected ):
4476
4482
# Chunk at open time
4477
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4483
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4484
+ tmp_file , chunks = (1 , 2 , 2 )
4485
+ ) as actual :
4478
4486
4479
4487
import dask .array as da
4480
4488
@@ -4496,7 +4504,7 @@ def test_chunks(self):
4496
4504
def test_pickle_rasterio (self ):
4497
4505
# regression test for https://github.com/pydata/xarray/issues/2121
4498
4506
with create_tmp_geotiff () as (tmp_file , expected ):
4499
- with xr .open_rasterio (tmp_file ) as rioda :
4507
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4500
4508
temp = pickle .dumps (rioda )
4501
4509
with pickle .loads (temp ) as actual :
4502
4510
assert_equal (actual , rioda )
@@ -4548,7 +4556,7 @@ def test_ENVI_tags(self):
4548
4556
}
4549
4557
expected = DataArray (data , dims = ("band" , "y" , "x" ), coords = coords )
4550
4558
4551
- with xr .open_rasterio (tmp_file ) as rioda :
4559
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4552
4560
assert_allclose (rioda , expected )
4553
4561
assert isinstance (rioda .attrs ["crs" ], str )
4554
4562
assert isinstance (rioda .attrs ["res" ], tuple )
@@ -4563,7 +4571,7 @@ def test_ENVI_tags(self):
4563
4571
def test_geotiff_tags (self ):
4564
4572
# Create a geotiff file with some tags
4565
4573
with create_tmp_geotiff () as (tmp_file , _ ):
4566
- with xr .open_rasterio (tmp_file ) as rioda :
4574
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4567
4575
assert isinstance (rioda .attrs ["AREA_OR_POINT" ], str )
4568
4576
4569
4577
@requires_dask
@@ -4578,7 +4586,9 @@ def test_no_mftime(self):
4578
4586
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4579
4587
) as (tmp_file , expected ):
4580
4588
with mock .patch ("os.path.getmtime" , side_effect = OSError ):
4581
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4589
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4590
+ tmp_file , chunks = (1 , 2 , 2 )
4591
+ ) as actual :
4582
4592
import dask .array as da
4583
4593
4584
4594
assert isinstance (actual .data , da .Array )
@@ -4589,10 +4599,12 @@ def test_http_url(self):
4589
4599
# more examples urls here
4590
4600
# http://download.osgeo.org/geotiff/samples/
4591
4601
url = "http://download.osgeo.org/geotiff/samples/made_up/ntf_nord.tif"
4592
- with xr .open_rasterio (url ) as actual :
4602
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (url ) as actual :
4593
4603
assert actual .shape == (1 , 512 , 512 )
4594
4604
# make sure chunking works
4595
- with xr .open_rasterio (url , chunks = (1 , 256 , 256 )) as actual :
4605
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4606
+ url , chunks = (1 , 256 , 256 )
4607
+ ) as actual :
4596
4608
import dask .array as da
4597
4609
4598
4610
assert isinstance (actual .data , da .Array )
@@ -4604,7 +4616,9 @@ def test_rasterio_environment(self):
4604
4616
# Should fail with error since suffix not allowed
4605
4617
with pytest .raises (Exception ):
4606
4618
with rasterio .Env (GDAL_SKIP = "GTiff" ):
4607
- with xr .open_rasterio (tmp_file ) as actual :
4619
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4620
+ tmp_file
4621
+ ) as actual :
4608
4622
assert_allclose (actual , expected )
4609
4623
4610
4624
@pytest .mark .xfail (reason = "rasterio 1.1.1 is broken. GH3573" )
@@ -4621,7 +4635,7 @@ def test_rasterio_vrt(self):
4621
4635
# Value of single pixel in center of image
4622
4636
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4623
4637
expected_val = next (vrt .sample ([(lon , lat )]))
4624
- with xr .open_rasterio (vrt ) as da :
4638
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4625
4639
actual_shape = (da .sizes ["x" ], da .sizes ["y" ])
4626
4640
actual_crs = da .crs
4627
4641
actual_res = da .res
@@ -4675,7 +4689,7 @@ def test_rasterio_vrt_with_src_crs(self):
4675
4689
with rasterio .open (tmp_file ) as src :
4676
4690
assert src .crs is None
4677
4691
with rasterio .vrt .WarpedVRT (src , src_crs = src_crs ) as vrt :
4678
- with xr .open_rasterio (vrt ) as da :
4692
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4679
4693
assert da .crs == src_crs
4680
4694
4681
4695
@network
@@ -4695,7 +4709,7 @@ def test_rasterio_vrt_network(self):
4695
4709
# Value of single pixel in center of image
4696
4710
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4697
4711
expected_val = next (vrt .sample ([(lon , lat )]))
4698
- with xr .open_rasterio (vrt ) as da :
4712
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4699
4713
actual_shape = da .sizes ["x" ], da .sizes ["y" ]
4700
4714
actual_res = da .res
4701
4715
actual_val = da .sel (dict (x = lon , y = lat ), method = "nearest" ).data
0 commit comments