Git Product home page Git Product logo

godal's People

Contributors

andyzimmerman1 avatar codingmarmot avatar dependabot[bot] avatar dimastark avatar fhelen avatar gcollot avatar pericles-tpt avatar rouault avatar tbonfort avatar thomascoquet avatar yohancabion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

godal's Issues

Enhancement: support context cancellation

Hello Thomas,

When used within a tile server, it happens often that tile requests get canceled by OpenLayers or Leaflet when the user pans/zooms faster than the server throughput. godal does not support context cancellation, what can waste (a lot of) resources in such cases. Cancelling early could be quite beneficial.

Obviously, one cannot cancel a cgo call from the go runtime and I expect an implementation in C++ to be complex.
However, one could still cancel early at the io level (in osio), resulting in resource savings.

I did a dumb example at the Adapter level. Basically, the idea is to combine the key with a context id, to register the context in a global map and to fetch it when doing io in osio.

var mutex sync.Mutex
var contexts map[string]context.Context

func unwrapkey(key string) string {
	last := strings.LastIndex(key, "#")
	if last != -1 {
		key = key[:last]
	}
	return key
}

func WithContext(ctx context.Context, key string) string {
	mutex.Lock()
	defer mutex.Unlock()

	cid := uuid.New().String()
	contexts[cid] = ctx
	return fmt.Sprintf("%s#%s", key, cid)
}

func GetContext(key string) (context.Context, string) {
	mutex.Lock()
	defer mutex.Unlock()

	last := strings.LastIndex(key, "#")
	if last == -1 {
		return context.Background(), key
	}
	ctx, ok := contexts[key[last+1:]]
	if !ok {
		ctx = context.Background()
	}
	key = key[:last]
	return ctx, key
}

func init() {
	contexts = map[string]context.Context{}
	// todo: launch goroutine and clean done contexts
}
type KeyStreamerAt interface {
	StreamAt(ctx context.Context, key string, off int64, n int64) (io.ReadCloser, int64, error)
}
func (a *Adapter) srcStreamAt(key string, off int64, n int64) (io.ReadCloser, error) {
	ctx, key := GetContext(key)
        ...
}

As simple as it may be, it works well enough. We could imagine WarpWithContext(ctx, ...), etc.
Hope all of this makes sense.
Thomas

compatibility with HDF5

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

Use static linking including all used C libraries within the executable binary

Dear Godal team,
Thanks for the great library. I wrote a simple application with it and it runs smoothly on my pc.
My overall goal is to run it in a AWS Lambda function, but i have problems to compile it in a way that it is working.

I tried several builds in a docker, but none of them worked. From what I learned, is that I have theoretically two possibities:

My question is, if you maybe have tried it already to run it in AWS Lambda or if you have a running Docker example?

Thanks for your help,
Marcel

NoData and WarpInto

Hello Thomas,

I am having issue getting nodata right with WarpInto when different from 0.
Below are three attempts to get it right but the read stays desperately at 0.
Any idea about what I am doing wrong?

Thanks, Thomas

func TestDatasetWarpInto_NoDataSetAtDst(t *testing.T) {
	os.Setenv("CPL_DEBUG", "ON")
	srs4326, _ := NewSpatialRefFromEPSG(4326)

	srcDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	srcDS.SetSpatialRef(srs4326)
	srcDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer srcDS.Close()

	dstDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	dstDS.SetSpatialRef(srs4326)
	dstDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer dstDS.Close()

	// set nodata value to src and dst
	for _, b := range srcDS.Bands() {
		b.SetNoData(255)
		assert.Nil(t, b.Fill(255, 0))
	}

	for _, b := range dstDS.Bands() {
		b.SetNoData(255)
	}

	// warp into
	assert.Nil(t, dstDS.WarpInto([]*Dataset{srcDS}, []string{}))

	data := make([]uint8, 1)
	assert.Nil(t, dstDS.Read(0, 0, data, 1, 1))
	assert.Equal(t, uint8(255), data[0])
}
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDAL_CACHEMAX = 786 MB
GDAL: GDALWARP: Defining SKIP_NOSOURCE=YES
GDAL: WARP: Copying metadata from first source to destination dataset
GDAL: GDAL: Computing area of interest: 45, 19, 61, 35
GDAL: OGRCT: Wrap source at 53.
OGRCT: Wrap target at 53.
GDAL: WARP: band=0 dstNoData=255.000000
GDAL: GDAL: GDALWarpKernel()::GWKNearestByte() Src=0,0,16x16 Dst=0,0,16x16
GDAL: GDAL: GDALClose(, this=0x199dfe0)
GDAL: GDAL: GDALClose(, this=0x199d3d0)
--- FAIL: TestDatasetWarpInto_NoDataSetAtDst (0.04s)
    /home/thomascoquet/Work/kayrros-godal/godal/godal_test.go:1863:
        	Error Trace:	godal_test.go:1863
        	Error:      	Not equal:
        	            	expected: 0xff
        	            	actual  : 0x0
        	Test:       	TestDatasetWarpInto_NoDataSetAtDst
func TestDatasetWarpInto_NoDataNoSet(t *testing.T) {
	os.Setenv("CPL_DEBUG", "ON")
	srs4326, _ := NewSpatialRefFromEPSG(4326)

	srcDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	srcDS.SetSpatialRef(srs4326)
	srcDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer srcDS.Close()

	dstDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	dstDS.SetSpatialRef(srs4326)
	dstDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer dstDS.Close()

	// set nodata value to src and dst
	for _, b := range srcDS.Bands() {
		b.SetNoData(255)
		assert.Nil(t, b.Fill(255, 0))
	}

	// warp into
	assert.Nil(t, dstDS.WarpInto([]*Dataset{srcDS}, []string{}))
	nodata, ok := dstDS.Bands()[0].NoData()
	assert.True(t, ok)
	assert.Equal(t, nodata, float64(255))

	data := make([]uint8, 1)
	assert.Nil(t, dstDS.Read(0, 0, data, 1, 1))
	assert.Equal(t, uint8(255), data[0])
}
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDAL_CACHEMAX = 786 MB
GDAL: GDALWARP: Defining SKIP_NOSOURCE=YES
GDAL: WARP: Copying metadata from first source to destination dataset
GDAL: GDAL: Computing area of interest: 45, 19, 61, 35
GDAL: OGRCT: Wrap source at 53.
OGRCT: Wrap target at 53.
GDAL: WARP: srcNoData=255.000000 dstNoData=255.000000
GDAL: GDAL: GDALWarpKernel()::GWKNearestByte() Src=0,0,16x16 Dst=0,0,16x16
GDAL: GDAL: GDALClose(, this=0x2e3efe0)
GDAL: GDAL: GDALClose(, this=0x2e3e3d0)
--- FAIL: TestDatasetWarpInto_NoDataNoSet (0.03s)
    /home/thomascoquet/Work/kayrros-godal/godal/godal_test.go:1911:
        	Error Trace:	godal_test.go:1911
        	Error:      	Should be true
        	Test:       	TestDatasetWarpInto_NoDataNoSet
    /home/thomascoquet/Work/kayrros-godal/godal/godal_test.go:1912:
        	Error Trace:	godal_test.go:1912
        	Error:      	Not equal:
        	            	expected: 0
        	            	actual  : 255
        	Test:       	TestDatasetWarpInto_NoDataNoSet
    /home/thomascoquet/Work/kayrros-godal/godal/godal_test.go:1916:
        	Error Trace:	godal_test.go:1916
        	Error:      	Not equal:
        	            	expected: 0xff
        	            	actual  : 0x0
        	Test:       	TestDatasetWarpInto_NoDataNoSet
func TestDatasetWarpInto_NoDataWithSwitch(t *testing.T) {
	os.Setenv("CPL_DEBUG", "ON")
	srs4326, _ := NewSpatialRefFromEPSG(4326)

	srcDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	srcDS.SetSpatialRef(srs4326)
	srcDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer srcDS.Close()

	dstDS, _ := Create(Memory, "", 1, Byte, 16, 16)
	dstDS.SetSpatialRef(srs4326)
	dstDS.SetGeoTransform([6]float64{45, 1, 0, 35, 0, -1})
	defer dstDS.Close()

	// set nodata value to src and dst
	for _, b := range srcDS.Bands() {
		b.SetNoData(255)
		assert.Nil(t, b.Fill(255, 0))
	}

	// warp into
	assert.Nil(t, dstDS.WarpInto([]*Dataset{srcDS}, []string{"-dstnodata", "255"}))
	data := make([]uint8, 1)
	assert.Nil(t, dstDS.Read(0, 0, data, 1, 1))
	assert.Equal(t, uint8(255), data[0])
}
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDALDriver::Create(MEM,,16,16,1,Byte,(nil))
GDAL: GDAL: GDAL_CACHEMAX = 786 MB
GDAL: GDALWARP: Defining SKIP_NOSOURCE=YES
GDAL: WARP: Copying metadata from first source to destination dataset
GDAL: GDAL: Computing area of interest: 45, 19, 61, 35
GDAL: OGRCT: Wrap source at 53.
OGRCT: Wrap target at 53.
GDAL: WARP: dstnodata of band 0 set to 255.000000
GDAL: GDAL: GDALWarpKernel()::GWKNearestByte() Src=0,0,16x16 Dst=0,0,16x16
GDAL: GDAL: GDALClose(, this=0x2e0ffe0)
GDAL: GDAL: GDALClose(, this=0x2e0f3d0)
--- FAIL: TestDatasetWarpInto_NoDataWithSwitch (0.04s)
    /home/thomascoquet/Work/kayrros-godal/godal/godal_test.go:1975:
        	Error Trace:	godal_test.go:1975
        	Error:      	Not equal:
        	            	expected: 0xff
        	            	actual  : 0x0
        	Test:       	TestDatasetWarpInto_NoDataWithSwitch

Running on Apple silicon

I'm wondering if there is any hope of using godal with gdal built for macOS-arm64. My first attempt failed with

ld: symbol(s) not found for architecture x86_64

Cannot get driver GTiff

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()

Rasterize questions?

Sorry to bother you again.
How to do Rasterize? there are two ways in godal.go

the first one is

func (ds *Dataset) Rasterize(dstDS string, switches []string, opts ...RasterizeOption) (*Dataset, error) {
....
}
  • what's the means of switches ?
  • the dstDS is the target raster file path?
  • the return value *Dataset is the rasterized dataset?
  • the ds *Dataset is the opened vector dataset?

If I want to use some field to bured, how can I get that? such as -where 'class="A"' -l footprints

gdal_rasterize -a ROOF_H -where 'class="A"' -l footprints footprints.shp city_dem.tif

issue building in Alpine container

When building an app using godal in alpine I get this error. The app builds fine on my Ubuntu machine. Can anyone point me in the right direction?

4.548 # github.com/airbusgeo/godal
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/errors.go:37:27: undefined: ErrorCategory
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:138:28: undefined: ResamplingAlg
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:159:8: undefined: Band
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:179:17: undefined: Band
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:180:17: undefined: Band
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:197:17: undefined: Band
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:277:15: undefined: ResamplingAlg
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:310:41: undefined: ResamplingAlg
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:1013:4: undefined: ResamplingAlg
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:1062:8: undefined: Band
4.548 /go/pkg/mod/github.com/airbusgeo/[email protected]/options.go:1062:8: too many errors

Trouble opening NETCDF dataset

Hello Thomas,
I am trying to open a netcdf dataset (Sentinel 5P).

gdalinfo NETCDF:"/home/thomascoquet/product.nc":/PRODUCT/methane_mixing_ratio_bias_corrected -> works perfectly.

Using godal:

func TestOpen(t *testing.T) {
	godal.RegisterRaster(godal.GTiff)
	ds, err := godal.Open("/home/thomascoquet/test.tif")
	assert.Nil(t, err)
	ds.Close()
} 
// OK, not a problem of file access

func TestGeoloc(t *testing.T) {
	godal.RegisterRaster(
		//godal.DriverName("KEA"),
		//godal.DriverName("BAG"),
		//godal.DriverName("HDF5"),
		//godal.DriverName("HDF5Image"),
		//godal.DriverName("HDF4"),
		//godal.DriverName("HDF4Image"),
		godal.DriverName("GMT"),
		godal.DriverName("netCDF"),
	)
	ds, err := godal.Open(`NETCDF:"/home/thomascoquet/product.nc":/PRODUCT/methane_mixing_ratio_bias_corrected`)
	assert.Nil(t, err)
}
--- FAIL: TestGeoloc (0.00s)
    .../read_test.go:23: 
        	Error Trace:	read_test.go:23
        	Error:      	Expected nil, but got: &errors.errorString{s:"NETCDF:\"/home/thomascoquet/product.nc\":/PRODUCT/methane_mixing_ratio_bias_corrected: No such file or directory"}
        	Test:       	TestGeoloc

What is the right syntax to open a subdataset? Reading the doc:

name may be a filename or any supported string supported by gdal (e.g. a /vsixxx path,
the xml string representing a vrt dataset, etc...)

I was expecting it to work.

An example file:
wget --content-disposition --continue --user=s5pguest --password=s5pguest "https://s5phub.copernicus.eu/dhus/odata/v1/Products('3fcea3d2-daab-4fa0-a09d-91b52f20ba10')/\$value" -O product.nc

Thanks!

godal.Warp produces empty image

I wrote a small script to warp a small part of the image, but with godal.Warp it is not working.

The gdal command is:

gdalwarp /vsis3/rastless-tests/TUR_us-newyork_EOMAP_20190309_155148_SENT2_m0010_32bit.tif ./working.tif -t_srs EPSG:3857 -te -8243902 4961937 -8243197 4962527 -ts 256 256

The file is in an public s3 bucket, so testing on your side should work just fine. The produced file has 256 * 256px and is in the New York bay.

I wrote the complementary Golang code with godal:

package main

import "github.com/airbusgeo/godal"

func main() {
	godal.RegisterAll()

	filename := "/vsis3/rastless-tests/TUR_us-newyork_EOMAP_20190309_155148_SENT2_m0010_32bit.tif"
	ds, _ := godal.Open(filename)
	datasets := []*godal.Dataset{ds}

	// gdalwarp /vsis3/rastless-tests/TUR_us-newyork_EOMAP_20190309_155148_SENT2_m0010_32bit.tif ./working.tif -t_srs EPSG:3857 -te -8243902 4961937 -8243197 4962527 -ts 256 256
	options := []string{"-t_srs", "EPSG:3857", "-te", "-8243902", "4961937", "-8243197", "4962527", "-ts", "256", "256"}
	godal.Warp("./not_working.tif", datasets, options)
}

The file seems to be empty and I cannot display it in qgis. I think, that the data is written into the file in a wrong way, as the file size and all metadata are the same like the file which was produced with pure gdal.

It would be great if you could tell if I did a mistake or if it is a godal problem, which you can fix.

WarpInto: stack smashing detected

Hello Thomas,

I am posting this here as I did not manage to reproduce neither with gdalwarp nor the SWIG bindings for python.

I am having a very weird behavior with custom presigned URL (and hence quite long). Here's a test to reproduce (I removed all special characters in the query part):

package godal_test

import (
	"context"
	"fmt"
	"os"
	"testing"

	"github.com/airbusgeo/godal"
	"github.com/airbusgeo/osio"
	"github.com/stretchr/testify/assert"
)

var ErrLoger = godal.ErrLogger(func(ec godal.ErrorCategory, code int, msg string) error {
	fmt.Printf("[gdal-debug] %d - %d - %s\n", ec, code, msg)
	if ec < godal.CE_Warning {
		return nil
	}
	return fmt.Errorf("gdal: code %d (%s)", code, msg)
})

func TestS5P(t *testing.T) {
	os.Setenv("CPL_DEBUG", "ON")
	ctx := context.Background()

	// drivers and adapters
	godal.RegisterRaster(godal.GTiff, godal.Memory)
	httpr, err := osio.HTTPHandle(ctx)
	assert.Nil(t, err)
	httpa, err := osio.NewAdapter(httpr)
	assert.Nil(t, err)
	godal.RegisterVSIHandler("http://", httpa)
	godal.RegisterVSIHandler("https://", httpa)

	// open and warp
	uri := "https://meeo-s5p.s3.amazonaws.com/COGT/OFFL/L2__CO____/2018/07/12/S5P_OFFL_L2__CO_____20180712T110154_20180712T124324_03860_01_010100_20180718T164726_PRODUCT_carbonmonoxide_total_column_4326.tif?xjphxjasdvfdrd=2022j03j24T14j3A43j3A53Z&jjpxjexpires=1h&xjphxjissuer=userjjjinternaljjjjjjjjjjjjjjjjcatalog&xjphxjmehods=GETjjjHEAD&xjphxjsignture=v1jvOjjjsblsIjjjNIVEm70McGBjjjmR10RCFVqKigYIoHtyxjjjJ2KKhsKRSlvUfZTvrBQ2fVgal4e0MYMA5IVJ6jjj1sNGbCgjjjjjj&xjphxjsignedjparameters=xjphxjjreatedjjjxjphxjmethodsjjjxjphxjuserjjjxjphxjexpiresjjjxjphxjdddddd&xjphxjuser=userjjjinternaljjjt.coquet"
	src, err := godal.Open(uri, ErrLoger)
	assert.Nil(t, err)
	defer src.Close()

	// create an in-memory raster
	dst, err := godal.Create(godal.Memory, "", src.Structure().NBands, src.Structure().DataType, 512, 512, ErrLoger)
	assert.Nil(t, err)
	defer dst.Close()

	sr, err := godal.NewSpatialRefFromEPSG(3857)
	assert.Nil(t, err)
	assert.Nil(t, dst.SetSpatialRef(sr))
	assert.Nil(t, dst.SetGeoTransform([6]float64{0, 1222.99245256282, 0, 5.009377085697301e+06, 0, -1222.99245256282}))

	// warping
	assert.Nil(t, dst.WarpInto([]*godal.Dataset{src}, []string{}, ErrLoger))
}

Yields:

[gdal-debug] 1 - 0 - GDAL: GDALOpen(https://meeo-s5p.s3.amazonaws.com/COGT/OFFL/L2__CO____/2018/07/12/S5P_OFFL_L2__CO_____20180712T110154_20180712T124324_03860_01_010100_20180718T164726_PRODUCT_carbonmonoxide_total_column_4326.tif?xjphxjasdvfdrd=2022j03j24T14j3A43j3A53Z&jjpxjexpires=1h&xjphxjissuer=userjjjinternaljjjjjjjjjjjjjjjjcatalog&xjphxjmehods=GETjjjHEAD&xjphxjsignture=v1jvOjjjsblsIjjjNIVEm70McGBjjjmR10RCFVqKigYIoHtyxjjjJ2KKhsKRSlvUfZTvrBQ2fVgal4e0MYMA5IVJ6jjj1sNGbCgjjjjjj&xjphxjsignedjparameters=xjphxjjreatedjjjxjphxjmethodsjjjxjphxjuserjjjxjphxjexpiresjjjxjphxjdddddd&xjphxjuser=userjjjinternaljjjt.coquet, this=0x23cf7a0) succeeds as GTiff.
[gdal-debug] 1 - 0 - GDAL: GDALDriver::Create(MEM,,512,512,1,Float32,(nil))
[gdal-debug] 1 - 0 - GDALWARP: Defining SKIP_NOSOURCE=YES
[gdal-debug] 1 - 0 - WARP: Copying metadata from first source to destination dataset
*** stack smashing detected ***: <unknown> terminated
SIGABRT: abort
PC=0x7fe074027e87 m=0 sigcode=18446744073709551610
signal arrived during cgo execution

goroutine 20 [syscall]:
runtime.cgocall(0xa558b0, 0xc000159c38)
	/home/thomascoquet/sdk/go1.18beta1/src/runtime/cgocall.go:157 +0x5c fp=0xc000159c10 sp=0xc000159bd8 pc=0x40cf5c
github.com/airbusgeo/godal._Cfunc_godalDatasetWarpInto(0x26beaf0, 0x23d0ad0, 0x1, 0xc000406030, 0x0)
	_cgo_gotypes.go:1338 +0x45 fp=0xc000159c38 sp=0xc000159c10 pc=0xa2ab85
github.com/airbusgeo/godal.(*Dataset).WarpInto.func1({0x26beaf0?, {0x0?, 0xabeae0?}}, 0x413dd5?, {0xc000159ed8?, 0x1, 0xa81a00?}, 0xc000159d30, {0x0, 0x0})
	/home/thomascoquet/Work/kayrros-godal/godal/godal.go:956 +0x105 fp=0xc000159c88 sp=0xc000159c38 pc=0xa352e5
github.com/airbusgeo/godal.(*Dataset).WarpInto(0xc000406010, {0xc000159ed8, 0x1, 0x1}, {0xc000159dd0, 0x0, 0x0}, {0xc000159f00, 0x1, 0x1})
	/home/thomascoquet/Work/kayrros-godal/godal/godal.go:956 +0x237 fp=0xc000159d78 sp=0xc000159c88 pc=0xa350b7
github.com/airbusgeo/godal_test.TestS5P(0x0?)
	/home/thomascoquet/Work/kayrros-godal/godal/s5p_test.go:52 +0x615 fp=0xc000159f70 sp=0xc000159d78 pc=0xa54535
testing.tRunner(0xc0003031e0, 0xc2bf78)
	/home/thomascoquet/sdk/go1.18beta1/src/testing/testing.go:1410 +0x102 fp=0xc000159fc0 sp=0xc000159f70 pc=0x51ae42
testing.(*T).Run.func1()
	/home/thomascoquet/sdk/go1.18beta1/src/testing/testing.go:1457 +0x2a fp=0xc000159fe0 sp=0xc000159fc0 pc=0x51bcea
runtime.goexit()
	/home/thomascoquet/sdk/go1.18beta1/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc000159fe8 sp=0xc000159fe0 pc=0x472081
created by testing.(*T).Run
	/home/thomascoquet/sdk/go1.18beta1/src/testing/testing.go:1457 +0x35f

Note that if you remove the period from my user id (t.coquet -> tcoquet), the error disappears.

The following python code was used to test GDAL. I saw no error on my side:

from osgeo import gdal, ogr
gdal.UseExceptions() 

uri = "..."
src = gdal.Open(uri)
driver = gdal.GetDriverByName('MEM')
dst = driver.Create('', 512, 512, 1, gdal.GDT_Float32, [])
sr = ogr.osr.SpatialReference()
sr.ImportFromEPSG(3857)
dst.SetSpatialRef(sr)
dst.SetGeoTransform([0,1222.99245256282,0,5.009377085697301e+06,0,-1222.99245256282])
gdal.Warp(dst, src)

Any idea?
Thanks


[UPDATE] gdal 3.0.4 locally, go 1.18, running on Ubuntu, latest godal version.
I have the same bug using osgeo/gdal:alpine-small-3.4.2

Rasterize questions?

Sorry to bother you again.
How to do Rasterize? there are two ways in godal.go

the first one is

func (ds *Dataset) Rasterize(dstDS string, switches []string, opts ...RasterizeOption) (*Dataset, error) {
....
}
  • what's the means of switches ?
  • the dstDS is the target raster file path?
  • the return value *Dataset is the rasterized dataset?
  • the ds *Dataset is the opened vector dataset?

If I want to use some field to bured, how can I get that? such as -where 'class="A"' -l footprints

gdal_rasterize -a ROOF_H -where 'class="A"' -l footprints footprints.shp city_dem.tif

Could not delete or restart the handle when used to connect to the AWS.

Hello!when I was reading the pictures on AWS with godal, I found that the godal did not change when I changed the pictures, and the pictures read were before the modification. I looked at the code and found that as long as I re-registered the handle, I could read the latest one, but I couldn't delete the previously registered handle. Can you give me some advice?

can not create the OpenJPEG format data

this is the code :

package main

import (
	"github.com/airbusgeo/godal"
)

func main() {
	godal.RegisterAll()
	tifname := "aa.tif"
	dsTif, _ := godal.Create(godal.GTiff, tifname, 1, godal.Byte, 20, 20)  // work
	dsTif.Close()

	jpegname := "bb.jpg"
	dsJpg, _ := godal.Create(godal.OpenJPEG, jpegname, 1, godal.Byte, 20, 20) // not work
	dsJpg.Close()
}

the error is

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4430e42]

goroutine 1 [running]:
github.com/airbusgeo/godal.(*Dataset).Close(0x0, 0x0, 0x0, 0x0, 0x1, 0x1)
        /Users/sshuair/go/pkg/mod/github.com/airbusgeo/[email protected]/godal.go:1283 +0xa2
main.main()
        /Users/sshuair/test/test.go:15 +0x12b
exit status 2

Error locating libgdal.dylib in macos

I was trying out the godal library (on my M1 Mac) and wrote a simple script as follows:

package main

import (
	"github.com/airbusgeo/godal"
)

func main() {
	godal.RegisterAll()
}

Running go run main.go throws the following error

dyld[19569]: Library not loaded: @rpath/libgdal.30.dylib
  Referenced from: /private/var/folders/y5/yh59dj093xn_dz8lm0mhv6lh0000gp/T/go-build1573968352/b001/exe/test
  Reason: tried: '/usr/local/lib/libgdal.30.dylib' (no such file), '/usr/lib/libgdal.30.dylib' (no such file)
signal: abort trap

godal has a dependency on gdal and I had installed it via conda. Due to this, the dylib is located under my conda folder - /Users/ash/miniconda3/lib not /usr/local/lib.

How can I have the program search for libgdal.dylib in /Users/ash/miniconda3/lib instead of /usr/local/lib ?

Had raised this question in StackOverflow previously but didn't get any solutions to this issue. Link - here

windwos not have gdal.pc

# pkg-config --cflags  -- gdal   
Package 'gdal' has no Name: field
pkg-config: exit status 1

Can you give some examples about the configuration of gdal.pc for windows? thk

go get error

I run the go get github.com/airbusgeo/godal, and got the follow error.

....
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1802:34: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1711:34: error: use of undeclared identifier 'oCC'
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1713:32: error: use of undeclared identifier 'oCC'
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1717:53: error: use of undeclared identifier 'oCC'
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1719:51: error: use of undeclared identifier 'oCC'
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1880:24: error: function definition does not declare parameters
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1883:15: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1885:15: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1893:24: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
/usr/local/Cellar/gdal/3.2.0_1/include/ogr_geometry.h:1914:49: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
....
fatal error: too many errors emitted, stopping now [-ferror-limit=]

buildVRT

Thank you very much for providing the GDAL library. I have a question here, could you help me? I need to convert this Rust code to Go using the GDAL library, but I have tested it many times without success. Is there any way to do it?

Here is the Rust code:

let src_wkt = CString::new(self.ds.spatial_ref()?.to_wkt()?)?;
let target_wkt = CString::new(sp_ref.to_wkt()?)?;

let mut str_opts = CslStringList::new();
str_opts.set_name_value("INIT_DEST", "NO_DATA")?;
str_opts.set_name_value("NUM_THREADS", "1")?;

let mut options = unsafe { GDALCreateWarpOptions() };
// use 2GB memory for warping (doesn't seem to help)
unsafe { (*options).dfWarpMemoryLimit = 2048. * 1024. * 1024. };
unsafe {
    (*options).papszWarpOptions = str_opts.as_ptr();
}

let vrt: GDALDatasetH = unsafe {
    GDALAutoCreateWarpedVRT(
        self.ds.c_dataset(),
        src_wkt.as_ptr(),
        target_wkt.as_ptr(),
        GDALResampleAlg::GRA_NearestNeighbour,
        0. as c_double,
        options,
    )
};

How do I read the window and resampling?

This is not an issue, but want some help.
I want to read part of the image from the large geotiff with resampling to some scaling.

  • upsampling: The read window is (0, 0, 1024, 1024) and the out image shape is 2048x2048.
  • downsampling: The read window is (0, 0, 2048, 2048) and the out image shape is 1024x1024.

And both the output image's bbox is same. How can I get this?

Could you do me a favor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.