You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New to golang and wanted to a get a feel for the language. My goal is read a geospatial raster (using godal) as a multi dimensional tensor via gorgonia/tensor . I was able to read the raster and convert it into a list of t.Dense but I'm kinda stuck at how to merge them together. Any suggestions?
package main
import (
"fmt"
"github.com/airbusgeo/godal"
t "gorgonia.org/tensor"
)
func main() {
godal.RegisterAll()
hDataset, err := godal.Open("data/LT5_19980329_sub.tif")
if err != nil {
panic(err)
}
structure := hDataset.Structure()
fmt.Printf("Size is %dx%dx%d\n", structure.SizeX, structure.SizeY, structure.NBands)
bands := hDataset.Bands()
count := len(bands)
fmt.Printf("Number of Bands: %d\n", count)
bandArrays := make([]*t.Dense, 0)
for i := range bands {
band := bands[i]
buf := make([]int16, structure.SizeX*structure.SizeY)
band.Read(0, 0, buf, structure.SizeY, structure.SizeX)
bandArray := t.New(t.WithShape(structure.SizeY, structure.SizeX, 1), t.WithBacking(buf))
bandArrays = append(bandArrays, bandArray)
}
fmt.Println("DONE!")
}
Would also appreciate any tips to improve this snippet if it is suboptimal.
The text was updated successfully, but these errors were encountered:
Hi all,
New to golang and wanted to a get a feel for the language. My goal is read a geospatial raster (using
godal
) as a multi dimensional tensor viagorgonia/tensor
. I was able to read the raster and convert it into a list oft.Dense
but I'm kinda stuck at how to merge them together. Any suggestions?Would also appreciate any tips to improve this snippet if it is suboptimal.
The text was updated successfully, but these errors were encountered: