@@ -4212,15 +4212,15 @@ class TestRasterio:
4212
4212
def test_serialization (self ):
4213
4213
with create_tmp_geotiff (additional_attrs = {}) as (tmp_file , expected ):
4214
4214
# Write it to a netcdf and read again (roundtrip)
4215
- with xr .open_rasterio (tmp_file ) as rioda :
4215
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4216
4216
with create_tmp_file (suffix = ".nc" ) as tmp_nc_file :
4217
4217
rioda .to_netcdf (tmp_nc_file )
4218
4218
with xr .open_dataarray (tmp_nc_file ) as ncds :
4219
4219
assert_identical (rioda , ncds )
4220
4220
4221
4221
def test_utm (self ):
4222
4222
with create_tmp_geotiff () as (tmp_file , expected ):
4223
- with xr .open_rasterio (tmp_file ) as rioda :
4223
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4224
4224
assert_allclose (rioda , expected )
4225
4225
assert rioda .attrs ["scales" ] == (1.0 , 1.0 , 1.0 )
4226
4226
assert rioda .attrs ["offsets" ] == (0.0 , 0.0 , 0.0 )
@@ -4236,7 +4236,9 @@ def test_utm(self):
4236
4236
)
4237
4237
4238
4238
# Check no parse coords
4239
- with xr .open_rasterio (tmp_file , parse_coordinates = False ) as rioda :
4239
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4240
+ tmp_file , parse_coordinates = False
4241
+ ) as rioda :
4240
4242
assert "x" not in rioda .coords
4241
4243
assert "y" not in rioda .coords
4242
4244
@@ -4248,7 +4250,7 @@ def test_non_rectilinear(self):
4248
4250
transform = from_origin (0 , 3 , 1 , 1 ).rotation (45 ), crs = None
4249
4251
) as (tmp_file , _ ):
4250
4252
# Default is to not parse coords
4251
- with xr .open_rasterio (tmp_file ) as rioda :
4253
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4252
4254
assert "x" not in rioda .coords
4253
4255
assert "y" not in rioda .coords
4254
4256
assert "crs" not in rioda .attrs
@@ -4276,7 +4278,7 @@ def test_platecarree(self):
4276
4278
crs = "+proj=latlong" ,
4277
4279
open_kwargs = {"nodata" : - 9765 },
4278
4280
) as (tmp_file , expected ):
4279
- with xr .open_rasterio (tmp_file ) as rioda :
4281
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4280
4282
assert_allclose (rioda , expected )
4281
4283
assert rioda .attrs ["scales" ] == (1.0 ,)
4282
4284
assert rioda .attrs ["offsets" ] == (0.0 ,)
@@ -4324,7 +4326,7 @@ def test_notransform(self):
4324
4326
"x" : [0.5 , 1.5 , 2.5 , 3.5 ],
4325
4327
},
4326
4328
)
4327
- with xr .open_rasterio (tmp_file ) as rioda :
4329
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4328
4330
assert_allclose (rioda , expected )
4329
4331
assert rioda .attrs ["scales" ] == (1.0 , 1.0 , 1.0 )
4330
4332
assert rioda .attrs ["offsets" ] == (0.0 , 0.0 , 0.0 )
@@ -4339,7 +4341,9 @@ def test_indexing(self):
4339
4341
with create_tmp_geotiff (
4340
4342
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4341
4343
) as (tmp_file , expected ):
4342
- with xr .open_rasterio (tmp_file , cache = False ) as actual :
4344
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4345
+ tmp_file , cache = False
4346
+ ) as actual :
4343
4347
4344
4348
# tests
4345
4349
# assert_allclose checks all data + coordinates
@@ -4455,7 +4459,7 @@ def test_caching(self):
4455
4459
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4456
4460
) as (tmp_file , expected ):
4457
4461
# Cache is the default
4458
- with xr .open_rasterio (tmp_file ) as actual :
4462
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as actual :
4459
4463
4460
4464
# This should cache everything
4461
4465
assert_allclose (actual , expected )
@@ -4471,7 +4475,9 @@ def test_chunks(self):
4471
4475
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4472
4476
) as (tmp_file , expected ):
4473
4477
# Chunk at open time
4474
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4478
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4479
+ tmp_file , chunks = (1 , 2 , 2 )
4480
+ ) as actual :
4475
4481
4476
4482
import dask .array as da
4477
4483
@@ -4493,7 +4499,7 @@ def test_chunks(self):
4493
4499
def test_pickle_rasterio (self ):
4494
4500
# regression test for https://github.com/pydata/xarray/issues/2121
4495
4501
with create_tmp_geotiff () as (tmp_file , expected ):
4496
- with xr .open_rasterio (tmp_file ) as rioda :
4502
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4497
4503
temp = pickle .dumps (rioda )
4498
4504
with pickle .loads (temp ) as actual :
4499
4505
assert_equal (actual , rioda )
@@ -4545,7 +4551,7 @@ def test_ENVI_tags(self):
4545
4551
}
4546
4552
expected = DataArray (data , dims = ("band" , "y" , "x" ), coords = coords )
4547
4553
4548
- with xr .open_rasterio (tmp_file ) as rioda :
4554
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4549
4555
assert_allclose (rioda , expected )
4550
4556
assert isinstance (rioda .attrs ["crs" ], str )
4551
4557
assert isinstance (rioda .attrs ["res" ], tuple )
@@ -4560,7 +4566,7 @@ def test_ENVI_tags(self):
4560
4566
def test_geotiff_tags (self ):
4561
4567
# Create a geotiff file with some tags
4562
4568
with create_tmp_geotiff () as (tmp_file , _ ):
4563
- with xr .open_rasterio (tmp_file ) as rioda :
4569
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (tmp_file ) as rioda :
4564
4570
assert isinstance (rioda .attrs ["AREA_OR_POINT" ], str )
4565
4571
4566
4572
@requires_dask
@@ -4575,7 +4581,9 @@ def test_no_mftime(self):
4575
4581
8 , 10 , 3 , transform_args = [1 , 2 , 0.5 , 2.0 ], crs = "+proj=latlong"
4576
4582
) as (tmp_file , expected ):
4577
4583
with mock .patch ("os.path.getmtime" , side_effect = OSError ):
4578
- with xr .open_rasterio (tmp_file , chunks = (1 , 2 , 2 )) as actual :
4584
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4585
+ tmp_file , chunks = (1 , 2 , 2 )
4586
+ ) as actual :
4579
4587
import dask .array as da
4580
4588
4581
4589
assert isinstance (actual .data , da .Array )
@@ -4586,10 +4594,12 @@ def test_http_url(self):
4586
4594
# more examples urls here
4587
4595
# http://download.osgeo.org/geotiff/samples/
4588
4596
url = "http://download.osgeo.org/geotiff/samples/made_up/ntf_nord.tif"
4589
- with xr .open_rasterio (url ) as actual :
4597
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (url ) as actual :
4590
4598
assert actual .shape == (1 , 512 , 512 )
4591
4599
# make sure chunking works
4592
- with xr .open_rasterio (url , chunks = (1 , 256 , 256 )) as actual :
4600
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4601
+ url , chunks = (1 , 256 , 256 )
4602
+ ) as actual :
4593
4603
import dask .array as da
4594
4604
4595
4605
assert isinstance (actual .data , da .Array )
@@ -4601,7 +4611,9 @@ def test_rasterio_environment(self):
4601
4611
# Should fail with error since suffix not allowed
4602
4612
with pytest .raises (Exception ):
4603
4613
with rasterio .Env (GDAL_SKIP = "GTiff" ):
4604
- with xr .open_rasterio (tmp_file ) as actual :
4614
+ with pytest .warns (DeprecationWarning ), xr .open_rasterio (
4615
+ tmp_file
4616
+ ) as actual :
4605
4617
assert_allclose (actual , expected )
4606
4618
4607
4619
@pytest .mark .xfail (reason = "rasterio 1.1.1 is broken. GH3573" )
@@ -4618,7 +4630,7 @@ def test_rasterio_vrt(self):
4618
4630
# Value of single pixel in center of image
4619
4631
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4620
4632
expected_val = next (vrt .sample ([(lon , lat )]))
4621
- with xr .open_rasterio (vrt ) as da :
4633
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4622
4634
actual_shape = (da .sizes ["x" ], da .sizes ["y" ])
4623
4635
actual_crs = da .crs
4624
4636
actual_res = da .res
@@ -4672,7 +4684,7 @@ def test_rasterio_vrt_with_src_crs(self):
4672
4684
with rasterio .open (tmp_file ) as src :
4673
4685
assert src .crs is None
4674
4686
with rasterio .vrt .WarpedVRT (src , src_crs = src_crs ) as vrt :
4675
- with xr .open_rasterio (vrt ) as da :
4687
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4676
4688
assert da .crs == src_crs
4677
4689
4678
4690
@network
@@ -4692,7 +4704,7 @@ def test_rasterio_vrt_network(self):
4692
4704
# Value of single pixel in center of image
4693
4705
lon , lat = vrt .xy (vrt .width // 2 , vrt .height // 2 )
4694
4706
expected_val = next (vrt .sample ([(lon , lat )]))
4695
- with xr .open_rasterio (vrt ) as da :
4707
+ with pytest . warns ( DeprecationWarning ), xr .open_rasterio (vrt ) as da :
4696
4708
actual_shape = da .sizes ["x" ], da .sizes ["y" ]
4697
4709
actual_res = da .res
4698
4710
actual_val = da .sel (dict (x = lon , y = lat ), method = "nearest" ).data
0 commit comments