Godal aims at providing an idiomatic go wrapper around the GDAL library:
hDS = GDALOpen(filename, GA_Readonly)
if (hDS == NULL) exit(1);
int sx = GDALGetRasterXSize(hDS);
int sy = GDALGetRasterYSize(hDS);
int nBands = GDALGetRasterCount(hDS);
printf("dataset size: %dx%dx%d\n",sx,sy,nBands);
for (int i=1; i<=nBands; i++) {
hBand = GDALGetRasterBand(hDS,i);
int ovrCount = GDALGetOverviewCount(hBand)
for(int o=0; o<=ovrCount; o++) {
GDALRasterBandH oBand = GDALGetOverview(hBand,o);
int osx = GDALGetRasterBandXSize(oBand);
int osy = GDALGetRasterBandYSize(oBand);
printf("overview %d size: %dx%d\n",o,osx,osy);
}
}
will be written as
hDS,err := godal.Open(filename)
if err!=nil {
panic(err)
}
structure := hDS.Structure()
fmt.Printf("dataset size: %dx%dx%d\n", structure.SizeX,structure.SizeY,structure.NBands)
for _,band := range hDS.Bands() {
for o,ovr := range band.Overviews() {
bstruct := ovr.Structure()
fmt.Printf("overview %d size: %dx%d\n",o,bstruct.SizeX,bstruct.SizeY)
}
}
ds,err := godal.Open(filename) //read-only
ds,err := godal.Open(filename, Update()) //read-write
gs://
google cloud storage URIs is
provided through https://github.com/airbusgeo/osio
contains the API reference and example code to get you started. The
*_test.go
files can also be used as reference.
Godal is not feature complete. The raster side is nearing completion and should remain stable. The vector and spatial-referencing sides are far from complete, meaning that the API might evolve in backwards incompatible ways until essential functionality is covered.
Contributions are welcome. Please read the contribution guidelines before submitting fixes or enhancements.
Godal requires a GDAL version greater than 3.0. Make sure the GDAL headers
are installed on the system used for compiling go+godal code. If using a GDAL
installation in a non standard location, you can set your PKG_CONFIG_PATH
environment variable, e.g. export PKG_CONFIG_PATH=/opt/include/pkgconfig
.
Godal is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.