airbusgeo / godal

golang wrapper for github.com/OSGEO/gdal
Apache License 2.0
137 stars 27 forks source link

Cannot get driver GTiff #120

Closed alienatorZ closed 11 months ago

alienatorZ commented 11 months ago

In running test code below I am getting the error failed to get driver GTiff.

I am in Ubuntu 20.04 linux and gdal seems to work fine from the command line.

tmpfile, _ := os.CreateTemp("/tmp", "")
    tmpfile.Close()
    dsfile := tmpfile.Name()
    defer os.Remove(dsfile)

    //create a 200x200 one band image, internally tiled with 32x32 blocks
    ds, err := godal.Create(godal.GTiff, dsfile, 1, godal.Byte, 200, 200, godal.CreationOption("TILED=YES", "BLOCKXSIZE=32", "BLOCKYSIZE=32"))

    if err != nil {
        fmt.Println(err)
    }

    //fill the band with random data
    buf := make([]byte, 200*200)
    for i := range buf {
        buf[i] = byte(rand.Intn(255))
    }
    bands := ds.Bands()
tbonfort commented 11 months ago

did you call godal.RegisterAll at some point beforehand?

alienatorZ commented 11 months ago

It looks like that was what I was missing. Thank you!