compatibility with HDF5
Closed this issue · 2 comments
thomascoquet commented
Hello Thomas,
I am trying to open an HDF5 file with godal.
The following fails locally (GDAL 3.4) and in the latest Docker image (ghcr.io/osgeo/gdal:alpine-normal-3.8.3
).
I used this test file: https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/data/hdf5/u8be.h5
package main
import (
"fmt"
"os"
"github.com/airbusgeo/godal"
)
func main() {
fmt.Println(godal.Version().Major(), godal.Version().Minor())
godal.RegisterInternalDrivers()
if err := godal.RegisterRaster("HDF5"); err != nil {
panic("could not register driver")
}
if _, err := os.Stat("/u8be.h5"); err == nil {
fmt.Println("file exists")
}
_, err := godal.Open(`/u8be.h5`)
if err != nil {
fmt.Println("trying to open file")
fmt.Println(err.Error())
}
_, err = godal.Open(`HDF5:"u8be.h5"://TestArray`)
if err != nil {
fmt.Println("trying to open subdataset")
fmt.Println(err.Error())
}
}
The error returned (with GDAL 3.8) is:
3 8
file exists
trying to open file
HDF5:"/u8be.h5"://TestArray: No such file or directory
trying to open subdataset
HDF5:"u8be.h5"://TestArray: No such file or directory
As it can be seen, the first read succeeds as GDAL manages to get the subdataset name, then it fails. gdalinfo
with the exact same path works as expected.
gdalinfo HDF5:"u8be.h5"://TestArray
0.335 Driver: HDF5Image/HDF5 Dataset
0.336 Files: u8be.h5
0.336 Size is 5, 6
0.336 Corner Coordinates:
0.336 Upper Left ( 0.0, 0.0)
0.336 Lower Left ( 0.0, 6.0)
0.336 Upper Right ( 5.0, 0.0)
0.336 Lower Right ( 5.0, 6.0)
0.336 Center ( 2.5, 3.0)
0.336 Band 1 Block=5x1 Type=Byte, ColorInterp=Undefined
Is there an uncompatibility between godal
and HDF5 files and where could I start looking?
Thanks
tbonfort commented
Maybe try using godal.RegisterAll()
instead of RegisterInternalDrivers()
?
thomascoquet commented
Indeed! GDAL dark magic.
Thanks :-)