|
23 | 23 | import numpy as np |
24 | 24 | import xarray as xr |
25 | 25 | from xarray.core import indexing |
26 | | -import rioxarray |
27 | | -import rasterio |
28 | 26 | import xee |
29 | 27 |
|
30 | 28 | import ee |
31 | 29 |
|
| 30 | +_SKIP_RASTERIO_TESTS = False |
| 31 | +try: |
| 32 | + import rasterio # pylint: disable=g-import-not-at-top |
| 33 | + import rioxarray # pylint: disable=g-import-not-at-top,unused-import |
| 34 | +except ImportError: |
| 35 | + _SKIP_RASTERIO_TESTS = True |
| 36 | + |
32 | 37 | _CREDENTIALS_PATH_KEY = 'GOOGLE_APPLICATION_CREDENTIALS' |
33 | 38 | _SCOPES = [ |
34 | 39 | 'https://www.googleapis.com/auth/cloud-platform', |
@@ -400,6 +405,7 @@ def test_validate_band_attrs(self): |
400 | 405 | for _, value in variable.attrs.items(): |
401 | 406 | self.assertIsInstance(value, valid_types) |
402 | 407 |
|
| 408 | + @absltest.skipIf(_SKIP_RASTERIO_TESTS, 'rioxarray module not loaded') |
403 | 409 | def test_write_projected_dataset_to_raster(self): |
404 | 410 | # ensure that a projected dataset written to a raster intersects with the |
405 | 411 | # point used to create the initial image collection |
@@ -436,6 +442,7 @@ def test_write_projected_dataset_to_raster(self): |
436 | 442 | intersects = bbox.intersects(point, 1, proj=proj) |
437 | 443 | self.assertTrue(intersects.getInfo()) |
438 | 444 |
|
| 445 | + @absltest.skipIf(_SKIP_RASTERIO_TESTS, 'rioxarray module not loaded') |
439 | 446 | def test_write_dataset_to_raster(self): |
440 | 447 | # ensure that a dataset written to a raster intersects with the point used |
441 | 448 | # to create the initial image collection |
|
0 commit comments