@@ -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
@@ -4279,7 +4281,7 @@ def test_platecarree(self):
4279
4281
crs = "+proj=latlong" ,
4280
4282
open_kwargs = {"nodata" : - 9765 },
4281
4283
) as (tmp_file , expected ):
4282
- with xr .open_rasterio (tmp_file ) as rioda :
4284
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4283
4285
assert_allclose (rioda , expected )
4284
4286
assert rioda .attrs ["scales" ] == (1.0 ,)
4285
4287
assert rioda .attrs ["offsets" ] == (0.0 ,)
@@ -4327,7 +4329,7 @@ def test_notransform(self):
4327
4329
"x" : [0.5 , 1.5 , 2.5 , 3.5 ],
4328
4330
},
4329
4331
)
4330
- with xr .open_rasterio (tmp_file ) as rioda :
4332
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4331
4333
assert_allclose (rioda , expected )
4332
4334
assert rioda .attrs ["scales" ] == (1.0 , 1.0 , 1.0 )
4333
4335
assert rioda .attrs ["offsets" ] == (0.0 , 0.0 , 0.0 )
@@ -4342,7 +4344,9 @@ def test_indexing(self):
4342
4344
with create_tmp_geotiff (
4343
4345
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4344
4346
) as (tmp_file , expected ):
4345
- with xr .open_rasterio (tmp_file , cache = False ) as actual :
4347
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4348
+ tmp_file , cache = False
4349
+ ) as actual :
4346
4350
4347
4351
# tests
4348
4352
# assert_allclose checks all data + coordinates
@@ -4458,7 +4462,7 @@ def test_caching(self):
4458
4462
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4459
4463
) as (tmp_file , expected ):
4460
4464
# Cache is the default
4461
- with xr .open_rasterio (tmp_file ) as actual :
4465
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as actual :
4462
4466
4463
4467
# This should cache everything
4464
4468
assert_allclose (actual , expected )
@@ -4474,7 +4478,9 @@ def test_chunks(self):
4474
4478
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4475
4479
) as (tmp_file , expected ):
4476
4480
# Chunk at open time
4477
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4481
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4482
+ tmp_file , chunks = (1 , 2 , 2 )
4483
+ ) as actual :
4478
4484
4479
4485
import dask .array as da
4480
4486
@@ -4496,7 +4502,7 @@ def test_chunks(self):
4496
4502
def test_pickle_rasterio (self ):
4497
4503
# regression test for https://github.com/pydata/xarray/issues/2121
4498
4504
with create_tmp_geotiff () as (tmp_file , expected ):
4499
- with xr .open_rasterio (tmp_file ) as rioda :
4505
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4500
4506
temp = pickle .dumps (rioda )
4501
4507
with pickle .loads (temp ) as actual :
4502
4508
assert_equal (actual , rioda )
@@ -4548,7 +4554,7 @@ def test_ENVI_tags(self):
4548
4554
}
4549
4555
expected = DataArray (data , dims = ("band" , "y" , "x" ), coords = coords )
4550
4556
4551
- with xr .open_rasterio (tmp_file ) as rioda :
4557
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4552
4558
assert_allclose (rioda , expected )
4553
4559
assert isinstance (rioda .attrs ["crs" ], str )
4554
4560
assert isinstance (rioda .attrs ["res" ], tuple )
@@ -4563,7 +4569,7 @@ def test_ENVI_tags(self):
4563
4569
def test_geotiff_tags (self ):
4564
4570
# Create a geotiff file with some tags
4565
4571
with create_tmp_geotiff () as (tmp_file , _ ):
4566
- with xr .open_rasterio (tmp_file ) as rioda :
4572
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4567
4573
assert isinstance (rioda .attrs ["AREA_OR_POINT" ], str )
4568
4574
4569
4575
@requires_dask
@@ -4578,7 +4584,9 @@ def test_no_mftime(self):
4578
4584
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4579
4585
) as (tmp_file , expected ):
4580
4586
with mock .patch ("os.path.getmtime" , side_effect = OSError ):
4581
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4587
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4588
+ tmp_file , chunks = (1 , 2 , 2 )
4589
+ ) as actual :
4582
4590
import dask .array as da
4583
4591
4584
4592
assert isinstance (actual .data , da .Array )
@@ -4589,10 +4597,12 @@ def test_http_url(self):
4589
4597
# more examples urls here
4590
4598
# http://download.osgeo.org/geotiff/samples/
4591
4599
url = "http://download.osgeo.org/geotiff/samples/made_up/ntf_nord.tif"
4592
- with xr .open_rasterio (url ) as actual :
4600
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (url ) as actual :
4593
4601
assert actual .shape == (1 , 512 , 512 )
4594
4602
# make sure chunking works
4595
- with xr .open_rasterio (url , chunks = (1 , 256 , 256 )) as actual :
4603
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4604
+ url , chunks = (1 , 256 , 256 )
4605
+ ) as actual :
4596
4606
import dask .array as da
4597
4607
4598
4608
assert isinstance (actual .data , da .Array )
@@ -4604,7 +4614,9 @@ def test_rasterio_environment(self):
4604
4614
# Should fail with error since suffix not allowed
4605
4615
with pytest .raises (Exception ):
4606
4616
with rasterio .Env (GDAL_SKIP = "GTiff" ):
4607
- with xr .open_rasterio (tmp_file ) as actual :
4617
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4618
+ tmp_file
4619
+ ) as actual :
4608
4620
assert_allclose (actual , expected )
4609
4621
4610
4622
@pytest .mark .xfail (reason = "rasterio 1.1.1 is broken. GH3573" )
@@ -4621,7 +4633,7 @@ def test_rasterio_vrt(self):
4621
4633
# Value of single pixel in center of image
4622
4634
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4623
4635
expected_val = next (vrt .sample ([(lon , lat )]))
4624
- with xr .open_rasterio (vrt ) as da :
4636
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4625
4637
actual_shape = (da .sizes ["x" ], da .sizes ["y" ])
4626
4638
actual_crs = da .crs
4627
4639
actual_res = da .res
@@ -4675,7 +4687,7 @@ def test_rasterio_vrt_with_src_crs(self):
4675
4687
with rasterio .open (tmp_file ) as src :
4676
4688
assert src .crs is None
4677
4689
with rasterio .vrt .WarpedVRT (src , src_crs = src_crs ) as vrt :
4678
- with xr .open_rasterio (vrt ) as da :
4690
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4679
4691
assert da .crs == src_crs
4680
4692
4681
4693
@network
@@ -4695,7 +4707,7 @@ def test_rasterio_vrt_network(self):
4695
4707
# Value of single pixel in center of image
4696
4708
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4697
4709
expected_val = next (vrt .sample ([(lon , lat )]))
4698
- with xr .open_rasterio (vrt ) as da :
4710
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4699
4711
actual_shape = da .sizes ["x" ], da .sizes ["y" ]
4700
4712
actual_res = da .res
4701
4713
actual_val = da .sel (dict (x = lon , y = lat ), method = "nearest" ).data
0 commit comments