add dem
This commit is contained in:
@@ -150,3 +150,27 @@ func setGeoTransform(ds *godal.Dataset, topLeftLng, topLeftLat, resolution float
|
||||
ds.SetMetadata("TIFFTAG_DATETIME", time.Now().String())
|
||||
ds.SetMetadata("TIFFTAG_SOFTWARE", "StarWiz-SJY01-IMAGE-PROC")
|
||||
}
|
||||
|
||||
func ReadTiff(tifFile string) ([][][]float32, error) {
|
||||
hDataset, err := godal.Open(tifFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var data [][][]float32
|
||||
for _, band := range hDataset.Bands() {
|
||||
structure := band.Structure()
|
||||
var dataBand [][]float32
|
||||
for y := 1; y <= structure.SizeY; y++ {
|
||||
scanline := make([]float32, structure.SizeX)
|
||||
err = band.Read(0, y, scanline, structure.SizeX, 1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dataBand = append(dataBand, scanline)
|
||||
}
|
||||
|
||||
data = append(data, dataBand)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user