File: test_subdatasets.py

package info (click to toggle)
rasterio 1.4.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,760 kB
  • sloc: python: 22,520; makefile: 275; sh: 164; xml: 29
file content (26 lines) | stat: -rw-r--r-- 825 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest

import rasterio

with rasterio.Env() as env:
    HAVE_NETCDF = "netCDF" in env.drivers().keys()
    HAVE_HDF5 = "HDF5" in env.drivers().keys()


@pytest.mark.skipif(not HAVE_NETCDF, reason="GDAL not compiled with NetCDF driver.")
def test_subdatasets():
    """Get subdataset names and descriptions"""
    with rasterio.open("netcdf:tests/data/RGB.nc") as src:
        subs = src.subdatasets
        assert len(subs) == 3
        for name in subs:
            assert name.startswith("netcdf")


@pytest.mark.skipif(not HAVE_HDF5, reason="GDAL not compiled with HDF5 driver.")
def test_subdatasets_h5():
    """Get subdataset names and descriptions"""
    with rasterio.open("tests/data/two-subs.h5") as src:
        subs = src.subdatasets
        assert len(subs) == 2
        assert src.profile["count"] == 0