Categorygithub.com/airbusgeo/godal
modulepackage
0.0.13
Repository: https://github.com/airbusgeo/godal.git
Documentation: pkg.go.dev

# README

Golang bindings for GDAL

Go Reference License Build Status Coverage Status Go Report Card

Goals

Godal aims at providing an idiomatic go wrapper around the GDAL library:

  • Function calls return a result and an error. The result will be valid if no error was returned. The error message will contain the root cause of why the error happened.
  • Calls between go and native libraries incur some overhead. As such godal does not strictly expose GDAL's API, but groups often-used calls in a single cgo function to reduce this overhead. For example, C code like
    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)
        }
    }
  • Unfrequently used or non-default parameters are passed as options:
    ds,err := godal.Open(filename) //read-only
    ds,err := godal.Open(filename, Update()) //read-write
  • Godal exposes a VSI handler that can easily allow you to expose an io.ReaderAt as a filename that can be opened by GDAL. A handler for opening gs:// google cloud storage URIs is provided through https://github.com/airbusgeo/osio

Documentation

GoReference contains the API reference and example code to get you started. The *_test.go files can also be used as reference.

Status

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.

Contributing

Contributions are welcome. Please read the contribution guidelines before submitting fixes or enhancements.

Installation

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.

Licensing

Godal is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

# Packages

No description provided by the author

# Functions

AllTouched is an option that can be passed to Dataset.RasterizeGeometries() where all pixels touched by lines or polygons will be updated, not just those on the line render path, or whose center point is within the polygon.
Approximate allows the histogram algorithm to operate on a subset of the full resolution data.
BandInterleaved makes Read return a band interleaved buffer instead of a pixel interleaved one.
Bands specifies which dataset bands should be read/written.
BandSpacing sets the number of bytes from one pixel to the next band of the same pixel.
BandStride sets the offset in the provided buffer from one pixel to the next band of the same pixel.
BlockIterator returns the blocks covering a sizeX,sizeY dataset.
ConfigOption sets a configuration option for a gdal library call.
CreationOption are options to pass to a driver when creating a dataset, to be passed in the form KEY=VALUE Examples are: BLOCKXSIZE=256, COMPRESS=LZW, NUM_THREADS=8, etc...
Destination makes SieveFilter output its result to the given band, instead of updating in-place.
Domain specifies the gdal metadata domain to use.
DriverOpenOption adds a list of Open Options (-oo switch) to the open command.
Drivers specifies the list of drivers that are allowed to try opening the dataset.
EightConnected is an option that switches pixel connectivity from 4 to 8.
EmulatedTx forces the driver to allow potentially slow transactions in a Vector Dataset if the driver does not have transaction mechanism deemed sufficiently performant by GDAL's maintainers.
ErrLogger is an option to override default error handling.
GCPProjection sets the projection string as an option for SetGCPs NOTE: A non-nil `sr` takes precedence over `projString`.
GCPSpatialRef sets the *SpatialRef as an option for SetGCPs NOTE: A non-nil `sr` takes precedence over `projString.
IncludeOutOfRange populates the first and last bucket with values under/over the specified min/max when used in conjuntion with Intervals().
IndirectSQLiteDialect forces GDAL to use Virtual Tables when the DataSource uses its native SQLiteDialect This should be used sparingly as it is highly likely to degrade performance.
Intervals computes a histogram with count buckets, spanning [min,max].
Levels set the overview levels to be computed.
LineSpacing sets the number of bytes from one pixel to the pixel of the same band one row below.
LineStride sets the offset in the provided buffer from one pixel to the pixel of the same band one row below.
Mask makes Polygonize or FillNoData use the given band as a nodata mask instead of using the source band's nodata mask.
MaxDistance is an option that can be passed to Band.FillNoData which sets the maximum number of pixels to search in all directions to find values to interpolate from.
MinSize makes BuildOverviews automatically compute the overview levels until the smallest overview size is less than s.
NoMask makes Polygonize ignore band nodata mask.
OGRSQLDialect is GDAL's built-in SQL dialect.
PixelSpacing sets the number of bytes from one pixel to the next pixel in the same row.
PixelStride sets the offset in the provided buffer from one pixel to the next pixel in the same row.
PixelValueFieldIndex makes Polygonize write the polygon's pixel value into the layer's fld'th field.
Resampling defines the resampling algorithm to use.
SiblingFiles specifies the list of files that may be opened alongside the prinicpal dataset name.
SignificantDigits sets the number of significant digits after the decimal separator should be kept for geojson output.
SmoothingIterations is an option that can be passed to Band.FillNoData which sets the number of 3x3 smoothing filter passes to run (0 or more).
SpatialFilter filters a ResultSet using the provided Geometry.
SQLiteDialect is an alternative to the OGRSQLDialect and may be used with any Vector Dataset If GDAL was compiled with Spatialite, this dialect will allow the usage of Spatialite functions.
Values sets the value(s) that must be rasterized in the dataset bands.
VSIHandlerBufferSize sets the size of the gdal-native block size used for caching.
VSIHandlerCacheSize sets the total number of gdal-native bytes used as cache *per handle*.
VSIHandlerStripPrefix allows to strip the prefix of the key when calling the underlying VSIKeyReader.
Window specifies the size of the dataset window to read/write.

# Constants

CSV comma-separated values driver.
DIMAP is a Dimap.
GeoJSON RFCxxxx geojson.
GeoPackage is a geo-package.
GTiff GeoTIFF.
HFA is an erdas img.
JP2KAK is a Kakadu Jpeg2000.
Memory in memory driver.
Mitab is a mapinfo mif/tab file.
OpenJPEG is an OpenJPEG JPEG2000.
Shapefile is an ESRI Shapefile.
VRT is a VRT.

# Variables

No description provided by the author

# Structs

BandStructure implements Structure for a Band.
Block is a window inside a dataset, starting at pixel X0,Y0 and spanning W,H pixels.
Bucket is a histogram entry.
DatasetStructure implements Structure for a Dataset.
Histogram is a band's histogram.
No description provided by the author
Statisitics on a given band.

# Interfaces

AddGeometryOption is an option passed to Geometry.AddGeometry() Available options are: - ErrLogger.
BandCreateMaskOption is an option that can be passed to Band.CreateMask() Available BandCreateMaskOptions are: - ConfigOption - ErrLogger.
BandIOOption is an option to modify the default behavior of band.IO Available BandIOOptions are: - PixelStride - LineStride - Window - Resampling - ConfigOption - PixelSpacing - LineSpacing.
BoundsOption is an option that can be passed to Dataset.Bounds or Geometry.Bounds Available options are: - *SpatialRef - ErrLogger.
BufferOption is an option passed to Geometry.Buffer() Available options are: - ErrLogger.
BuildOverviewsOption is an option to specify how overview building should behave.
BuildVRTOption is an option that can be passed to BuildVRT Available BuildVRTOptions are: - ConfigOption - DriverOpenOption - Bands - Resampling.
ClearOverviewsOption is an option passed to Dataset.ClearOverviews Available options are: - ErrLogger.
ClearStatistics is an option passed to Dataset.ClearStatisticsAvailable options are: -ErrLogger.
CloseOption is an option passed to Dataset.Close() Available options are: - ErrLogger.
CloseResultSetOption is an option that can be passed to ResultSet.Close There are currently no options available.
CommitTransactionOption is an option that can be passed to Dataset.CommitTransaction There are currently no options available.
CopyLayerOption is an option that can be passed to Dataset.CreateLayer().
CreateFeatureOption is an option that can be passed to Layer.CreateFeature Available options are: - none yet.
CreateLayerOption is an option that can be passed to Dataset.CreateLayer().
CreateSpatialRefOption is an option that can be passed when creating a new spatial reference object Available options are: - ErrLogger.
DatasetCreateMaskOption is an option that can be passed to Dataset.CreateMaskBand() Available DatasetCreateMaskOptions are: - ConfigOption.
DatasetCreateOption is an option that can be passed to Create() Available DatasetCreateOptions are: - CreationOption - ConfigOption - ErrLogger.
DatasetIOOption is an option to modify the default behavior of dataset.IO Available DatasetIOOptions are: - PixelStride - LineStride - BandStride - Window - Resampling - ConfigOption - Bands - BandInterleaved - PixelSpacing - LineSpacing - BandSpacing.
DatasetTranslateOption is an option that can be passed to Dataset.Translate() Available DatasetTranslateOptions are: - ConfigOption - CreationOption - DriverName.
DatasetVectorTranslateOption is an option that can be passed to Dataset.Warp() Available Options are: - CreationOption - ConfigOption - DriverName.
DatasetWarpIntoOption is an option that can be passed to Dataset.WarpInto() Available DatasetWarpIntoOption is: - ConfigOption.
DatasetWarpOption is an option that can be passed to Dataset.Warp() Available DatasetWarpOptions are: - ConfigOption - CreationOption - DriverName.
DeleteFeatureOption is an option passed to Layer.DeleteFeature() Available options are: - ErrLogger.
DemOption is an option that can be passed to Dataset.Dem().
DifferenceOption is an option passed to Geometry.Difference() Available options are: - ErrLogger.
ExecuteSQLOption is an option that can be passed to Dataset.ExecuteSQL Available options are: - SQLDialect - SpatialFilterOption.
FeatureCountOption is an option passed to Layer.FeatureCount() Available options are: - ErrLogger.
FillBandOption is an option that can be passed to Band.Fill() Available FillBandOptions are: - ErrLogger.
FillNoDataOption is an option that can be passed to band.FillNoData Available FillNoDataOptions are: - MaxDistance(int): The maximum distance (in pixels) that the algorithm will search out for values to interpolate.
GCPsToGeoTransformOption is an option that can be passed to GCPsToGeoTransform().
GeoJSONOption is an option that can be passed to Geometry.GeoJSON.
GeometryReprojectOption is an option passed to Geometry.Reproject() Available options are: - ErrLogger.
GeometryTransformOption is an option passed to Geometry.Transform() Available options are: - ErrLogger.
GeometryWKBOption is an option passed to Geometry.WKB() Available options are: - ErrLogger.
GeometryWKTOption is an option passed to Geometry.WKT() Available options are: - ErrLogger.
GetGeoTransformOption is an option that can be passed to Dataset.GeoTransform() Available GetGeoTransformOptions are: - ErrLogger.
GMLExportOption is an option passed to Geometry.GML() Available options are: - CreationOption - ErrLogger.
GridCreateOption is an option that can be passed to GridCreate Available options are: - none yet.
GridOption is an option that can be passed to Dataset.Grid().
HistogramOption is an option that can be passed to Band.Histogram() Available HistogramOptions are: - Approximate() to allow the algorithm to operate on a subset of the full resolution data - Intervals(count int, min,max float64) to compute a histogram with count buckets, spanning [min,max].
IntersectionOption is an option passed to Geometry.Intersection() Available options are: - ErrLogger.
IntersectsOption is an option passed to Geometry.Intersects() Available options are: - ErrLogger.
MetadataOption is an option that can be passed to metadata related calls Available MetadataOptions are: - Domain.
NearblackOption is an option that can be passed to Dataset.Nearblack().
NewFeatureOption is an option that can be passed to Layer.NewFeature Available options are: - none yet.
NewGeometryOption is an option passed when creating a geometry Available options are: - ErrLogger.
OpenOption is an option passed to Open() Available OpenOptions are: - Drivers - SiblingFiles - Shared - ConfigOption - Update - DriverOpenOption - RasterOnly - VectorOnly.
PolygonizeOption is an option to modify the default behavior of band.Polygonize Available PolygonizeOptions are: - EightConnected() to enable 8-connectivity.
RasterizeGeometryOption is an option that can be passed tp Dataset.RasterizeGeometry().
RasterizeIntoOption is an option that can be passed to DatasetRasterizeInto() Available RasterizeOptions are: - ConfigOption - ErrLogger.
RasterizeOption is an option that can be passed to Rasterize() Available RasterizeOptions are: - CreationOption - ConfigOption - DriverName - ErrLogger.
RegisterPluginOption is an option that can be passed to RegisterPlugin().
RollbackTransactionOption is an option that can be passed to Dataset.RollbackTransaction There are currently no options available.
SetColorInterpOption is an option that can be passed to Band.SetColorInterpretation() Available SetColorInterpOption are: - ErrLogger.
SetColorTableOption is an option that can be passed to Band.SetColorTable() Available SetColorTableOption are: - ErrLogger.
SetDescriptionOption is an option that can be passed to SetDescription Available SetDescriptionOptions are: - ErrLogger.
SetFieldValueOption is an option passed to Feature.SetFieldValue() Available options are: - ErrLogger.
SetGCPsOption is an option that can be passed to Dataset.SetGCPs().
SetGeometryColumnNameOption is an option passed to Layer.SetGeometryColumnName() or Feature.SetGeometryColumnName() Available options are: - ErrLogger.
SetGeometryOption is an option passed to Feature.SetGeometry() Available options are: - ErrLogger.
SetGeoTransformOption is an option that can be passed to Dataset.SetGeoTransform() Available SetGeoTransformOptions are: - ErrLogger.
SetNoDataOption is an option that can be passed to Band.SetNodata(), Band.ClearNodata(), Dataset.SetNodata() Available SetNoDataOptions are: - ErrLogger.
SetProjectionOption is an option that can be passed to Dataset.SetProjection Available SetProjection are: - ErrLogger.
SetScaleOffsetOption is an option that can be passed to Band.SetScaleOffset(), Band.ClearScaleOffset(), Dataset.SetScaleOffset() Available SetScaleOffsetOptions are: - ErrLogger.
SetSpatialRefOption is an option that can be passed to Dataset.SetSpatialRef Available SetProjection are: - ErrLogger.
SetStatistics is an option that can passed to Band.SetStatistics()Available options are: -ErrLogger.
SieveFilterOption is an option to modify the behavior of Band.SieveFilter Available SieveFilterOptions are: - EightConnected() to enable 8-connectivity.
SimplifyOption is an option passed to Geometry.Simplify() Available options are: - ErrLogger.
SpatialRefValidateOption is an option that can be passed to SpatialRef.Validate() Available SpatialRefValidateOptions are: - ErrLogger.
StartTransactionOption is an option that can be passed to Dataset.StartTransaction Available options are: - EmulateTx.
StatisticsOption is an option that can be passed to Band.Statistics Available Statistics options are: - Aproximate() to allow the satistics to be computed on overviews or a subset of all tiles.
SubGeometryOption is an option passed to Geometry.SubGeometry() Available options are: - ErrLogger.
TransformOption is an option that can be passed to NewTransform Available TransformOptions are: - ErrLogger.
UnionOption is an option passed to Geometry.Union() Available options are: - ErrLogger.
UpdateFeatureOption is an option passed to Layer.UpdateFeature() Available options are: - ErrLogger.
VSIHandlerOption is an option that can be passed to RegisterVSIHandler.
VSIOpenOption is an option passed to VSIOpen() Available options are: - ErrLogger.
VSIUnlinkOption is an option passed to VSIUnlink() Available options are: - ErrLogger.
WKTExportOption is an option that can be passed to SpatialRef.WKT() Available WKTExportOptions are: - ErrLogger.

# Type aliases

DriverName is GDAL driver.
EmulateTx By default, GDAL only allows transactions deemed by its maintainers to be sufficiently efficienct However it is possible to force the driver to use a potentially slow emulated by providing EmulatedTx to StartTransaction.
ErrorHandler is a function that can be used to override godal's default behavior of treating all messages with severity >= CE_Warning as errors.
SQLDialect is a SQL dialect that be passed to Dataset.ExecuteSQL Available options are: - OGRSQLDialect - SQLiteDialect - IndirectSQLiteDialect.