public void GdalInfoHdf5() { const string filename = @"HDF5\test.h5"; // Check if GDAL can open it: var utils = new Utils(); var settings = new GlobalSettings(); var info = utils.GDALInfo(filename, string.Empty); Assert.IsNotNull(info, "Could not read gdalinfo: " + settings.GdalLastErrorMsg); Debug.WriteLine(info); Assert.IsTrue(info.Contains("Driver: HDF5/Hierarchical Data Format Release 5"), "File is not recognized"); var ds = new GdalDataset(); if (ds.Open(filename, true)) { Debug.Print("Sub datasets"); for (int i = 0; i < ds.SubDatasetCount; i++) { string name = ds.GetSubDatasetName(i); Debug.Print(name); } } // Open HDF file using subset: var subset = $"HDF5:\"{filename}\"://image1/image_data"; var infoSubset = utils.GDALInfo(subset, string.Empty); Assert.IsNotNull(infoSubset, "Could not read gdalinfo: " + settings.GdalLastErrorMsg); Debug.WriteLine(infoSubset); Assert.IsTrue(infoSubset.Contains("Driver: HDF5Image/HDF5 Dataset"), "File is not recognized"); // Open subdataset as grid: var grd = new Grid(); var result = grd.Open(subset); Assert.IsTrue(result, "Could not open HDF5 subset as grid"); Debug.WriteLine(grd.NumBands); Debug.WriteLine(grd.Extents.ToDebugString()); Debug.WriteLine(grd.Minimum.ToString()); Debug.WriteLine(grd.Maximum.ToString()); }
public bool Open(string Filename, bool readOnly) { return(_dataset.Open(Filename, readOnly)); }