HAZE
haze is a drop-in replacement to process water vapor to be used with FORCE
Loading...
Searching...
No Matches
General GDAL Operations

Functions

GDALDatasetH openRasterDataset (const char *filePath)
 Open a raster dataset in read-only mode.
GDALRasterBandH openRasterBand (GDALDatasetH raster, int index)
 Fetch a raster band from an opened raster dataset.
GDALDatasetH openVectorDataset (const char *filePath)
 Open a vector dataset in read-only mode.
OGRLayerH openVectorLayer (GDALDatasetH vector, const char *name)
 Fetch a vector layer from an opened vector dataset.
void closeGDALDataset (GDALDatasetH dataset)
 Close an open raster or vector dataset.
CRS_TYPE getCRSType (const char *Wkt)
 Determine if a given CRS is geographic or planar/projected.
char * extractCRSAsWKT (GDALDatasetH dataset, const char *layerName)
 Return the dataset/layer CRS as WKT.
OGRCoordinateTransformationH transformationFromWKTs (char *from, char *to, bool inputUsesCompliantOrdering)
 Create a coordinate transformation between to CRS's.
GEOSGeometry * OGRToGEOS (const OGRGeometryH geom)
 Convert an OGR geometry to a GEOS geometry.
OGRGeometryH OGRFromGEOS (const GEOSGeometry *geom, OGRSpatialReferenceH crs)
 Convert a GEOS geometry to an OGR geometry.

Detailed Description

Function Documentation

◆ closeGDALDataset()

void closeGDALDataset ( GDALDatasetH dataset)

Close an open raster or vector dataset.

Note
This function may call exit(1) if closing the GDALDatasetH object failed.
Parameters
datasetObject to close.

◆ extractCRSAsWKT()

char * extractCRSAsWKT ( GDALDatasetH dataset,
const char * layerName )
nodiscard

Return the dataset/layer CRS as WKT.

This function works on raster and vector datasets. It extracts the the projection of the dataset and returns a new reference to its WKT representation.

Note
After the function returns, the caller owns the returned char * object and must free/destroy it after use with CPLFree.
Parameters
datasetGDAL dataset object to query for CRS infromation.
layerNameLayer name to query. Only honored for vector datasets.
Returns
char* Pointer to WKT string, NULL on error

◆ getCRSType()

CRS_TYPE getCRSType ( const char * Wkt)

Determine if a given CRS is geographic or planar/projected.

Note
If CRS type couldn't be fetched, CRS_UNKNOWN is returned indicating an error.
Parameters
WktString representation of CRS.
Returns
CRS_TYPE Type of CRS.

◆ OGRFromGEOS()

OGRGeometryH OGRFromGEOS ( const GEOSGeometry * geom,
OGRSpatialReferenceH crs )
nodiscard

Convert a GEOS geometry to an OGR geometry.

This function creates a temporary GEOS WKB-writer and converts the input GEOS geometry to a corresponding OGR geometry by ex-/importing via the respective WKB interfaces.

Note
After the function returns, the caller owns the returned OGRGeometryH object and must free/destroy it after use.
Warning
This function is not reentrant or thread-safe!
Parameters
geomGEOS geometry to convert.
crsSpatial reference object to assign to geometry, can be NULL.
Returns
OGRGeometryH Converted geometry, NULL on error.

◆ OGRToGEOS()

GEOSGeometry * OGRToGEOS ( const OGRGeometryH geom)
nodiscard

Convert an OGR geometry to a GEOS geometry.

This function creates a temporary GEOS WKB-reader and converts the input OGR geometry to a corresponding GEOS geometry by ex-/importing via the WKB interfaces.

Note
The C++-API of GDAL offers a direct interface to export OGR geometries to GEOS. Since GDAL's C-API does not offer such functionality, this workaround is needed.
After the function returns, the caller owns the returned GEOSGeometry object and must free/destroy it after use.
Warning
This function is not reentrant or thread-safe!
Parameters
geomOGR geometry to convert.
Returns
GEOSGeometry* Converted geometry, NULL on error.

◆ openRasterBand()

GDALRasterBandH openRasterBand ( GDALDatasetH raster,
int index )

Fetch a raster band from an opened raster dataset.

Note
The raster band indices are 1-based.
Remarks
The returned raster band is owned by the corresponding raster dataset and should not be freed/destroyed.
Parameters
rasterRaster object to fetch band from.
indexBand index.
Returns
GDALRasterBandH GDAL handle to raster band, NULL on failure.

◆ openRasterDataset()

GDALDatasetH openRasterDataset ( const char * filePath)
nodiscard

Open a raster dataset in read-only mode.

Remarks
After the function returns, the caller owns the returned GDALDatasetH object and must close it after use.
Parameters
filePathRaster file to open.
Returns
GDALDatasetH GDAL handle to opened dataset, NULL on failure.

◆ openVectorDataset()

GDALDatasetH openVectorDataset ( const char * filePath)
nodiscard

Open a vector dataset in read-only mode.

Warning
The GML and GMLLAS drivers are dregistered because it's explicitly mentioned they maybe not import coordinates in a "gis friendly" way!
Remarks
After the function returns, the caller owns the returned GDALDatasetH object and must close it after use.
Parameters
filePathVector file to open.
Returns
GDALDatasetH GDAL handle to opened dataset, NULL on failure.

◆ openVectorLayer()

OGRLayerH openVectorLayer ( GDALDatasetH vector,
const char * name )

Fetch a vector layer from an opened vector dataset.

Note
If name is null, the first vector layer is returned.
Remarks
The returned vector layer is owned by the corresponding vector dataset and should not be freed/destroyed.
Parameters
vectorVector object to fetch layer from.
nameLayer name to fetch, possibly NULL.
Returns
OGRLayerH GDAL handle to vector layer, NULL on failure.

◆ transformationFromWKTs()

OGRCoordinateTransformationH transformationFromWKTs ( char * from,
char * to,
bool inputUsesCompliantOrdering )

Create a coordinate transformation between to CRS's.

This function creates OGRSpatialReferenceH objects from the supplied WKT representations. The transformation object is created using the OCTNewCoordinateTransformationEx function, setting optional arguments to NULL. The returned coordinate transformation object can be used with various transformation API's offered by GDAL.

Remarks
The returned object is owned by the caller and must be freed/destroyed after use.
Parameters
fromSource CRS as WKT string.
toDestination CRS as WKT string.
inputUsesCompliantOrderingBoolean flag indicating if the CRS associated with the object to transform uses authority compliant ordering or gis friendly ordering. When data is read from file, this is most likely false.
Returns
OGRCoordinateTransformationH A new transformation object, NULL on error.