QGIS API Documentation  3.20.0-Odense (decaadbb31)
Static Public Member Functions | Friends | List of all members
QgsGdalUtils Class Reference

Utilities for working with GDAL. More...

#include <qgsgdalutils.h>

Static Public Member Functions

static gdal::dataset_unique_ptr createMultiBandMemoryDataset (GDALDataType dataType, int bands, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs)
 Creates a new multi band memory dataset with given parameters. More...
 
static gdal::dataset_unique_ptr createSingleBandMemoryDataset (GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs)
 Creates a new single band memory dataset with given parameters. More...
 
static gdal::dataset_unique_ptr createSingleBandTiffDataset (const QString &filename, GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs)
 Creates a new single band TIFF dataset with given parameters. More...
 
static QString helpCreationOptionsFormat (const QString &format)
 Gets creation options metadata for a given format. More...
 
static gdal::dataset_unique_ptr imageToMemoryDataset (const QImage &image)
 Converts an image to a GDAL memory dataset by borrowing image data. More...
 
static char ** papszFromStringList (const QStringList &list)
 Helper function. More...
 
static QImage resampleImage (const QImage &image, QSize outputSize, GDALRIOResampleAlg resampleAlg)
 Resamples a QImage image using GDAL resampler. More...
 
static bool resampleSingleBandRaster (GDALDatasetH hSrcDS, GDALDatasetH hDstDS, GDALResampleAlg resampleAlg, const char *pszCoordinateOperation)
 Resamples a single band raster to the destination dataset with different resolution (and possibly with different CRS). More...
 
static GDALDatasetH rpcAwareAutoCreateWarpedVrt (GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfMaxError, const GDALWarpOptions *psOptionsIn)
 This is a copy of GDALAutoCreateWarpedVRT optimized for imagery using RPC georeferencing that also sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF. More...
 
static void * rpcAwareCreateTransformer (GDALDatasetH hSrcDS, GDALDatasetH hDstDS=nullptr, char **papszOptions=nullptr)
 This is a wrapper around GDALCreateGenImgProjTransformer2() that takes into account RPC georeferencing (it sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF). More...
 
static void setupProxy ()
 Sets the gdal proxy variables. More...
 
static bool supportsRasterCreate (GDALDriverH driver)
 Reads whether a driver supports GDALCreate() for raster purposes. More...
 
static QString validateCreationOptionsFormat (const QStringList &createOptions, const QString &format)
 Validates creation options for a given format, regardless of layer. More...
 

Friends

class TestQgsGdalUtils
 

Detailed Description

Utilities for working with GDAL.

Note
not available in Python bindings
Since
QGIS 3.4

Definition at line 34 of file qgsgdalutils.h.

Member Function Documentation

◆ createMultiBandMemoryDataset()

gdal::dataset_unique_ptr QgsGdalUtils::createMultiBandMemoryDataset ( GDALDataType  dataType,
int  bands,
const QgsRectangle extent,
int  width,
int  height,
const QgsCoordinateReferenceSystem crs 
)
static

Creates a new multi band memory dataset with given parameters.

Since
QGIS 3.12

Definition at line 48 of file qgsgdalutils.cpp.

◆ createSingleBandMemoryDataset()

gdal::dataset_unique_ptr QgsGdalUtils::createSingleBandMemoryDataset ( GDALDataType  dataType,
const QgsRectangle extent,
int  width,
int  height,
const QgsCoordinateReferenceSystem crs 
)
static

Creates a new single band memory dataset with given parameters.

Since
QGIS 3.8

Definition at line 43 of file qgsgdalutils.cpp.

◆ createSingleBandTiffDataset()

gdal::dataset_unique_ptr QgsGdalUtils::createSingleBandTiffDataset ( const QString &  filename,
GDALDataType  dataType,
const QgsRectangle extent,
int  width,
int  height,
const QgsCoordinateReferenceSystem crs 
)
static

Creates a new single band TIFF dataset with given parameters.

Since
QGIS 3.8

Definition at line 73 of file qgsgdalutils.cpp.

◆ helpCreationOptionsFormat()

QString QgsGdalUtils::helpCreationOptionsFormat ( const QString &  format)
static

Gets creation options metadata for a given format.

Since
QGIS 3.10

Definition at line 236 of file qgsgdalutils.cpp.

◆ imageToMemoryDataset()

gdal::dataset_unique_ptr QgsGdalUtils::imageToMemoryDataset ( const QImage &  image)
static

Converts an image to a GDAL memory dataset by borrowing image data.

Warning
The image must exist unchanged for the lifetime of the returned gdal dataset!
Since
QGIS 3.12

Definition at line 104 of file qgsgdalutils.cpp.

◆ papszFromStringList()

char ** QgsGdalUtils::papszFromStringList ( const QStringList &  list)
static

Helper function.

Since
QGIS 3.10

Definition at line 265 of file qgsgdalutils.cpp.

◆ resampleImage()

QImage QgsGdalUtils::resampleImage ( const QImage &  image,
QSize  outputSize,
GDALRIOResampleAlg  resampleAlg 
)
static

Resamples a QImage image using GDAL resampler.

Since
QGIS 3.12

Definition at line 185 of file qgsgdalutils.cpp.

◆ resampleSingleBandRaster()

bool QgsGdalUtils::resampleSingleBandRaster ( GDALDatasetH  hSrcDS,
GDALDatasetH  hDstDS,
GDALResampleAlg  resampleAlg,
const char *  pszCoordinateOperation 
)
static

Resamples a single band raster to the destination dataset with different resolution (and possibly with different CRS).

Ideally the source dataset should cover the whole area or the destination dataset.

Returns
true on success
Since
QGIS 3.8

Definition at line 148 of file qgsgdalutils.cpp.

◆ rpcAwareAutoCreateWarpedVrt()

GDALDatasetH QgsGdalUtils::rpcAwareAutoCreateWarpedVrt ( GDALDatasetH  hSrcDS,
const char *  pszSrcWKT,
const char *  pszDstWKT,
GDALResampleAlg  eResampleAlg,
double  dfMaxError,
const GDALWarpOptions *  psOptionsIn 
)
static

This is a copy of GDALAutoCreateWarpedVRT optimized for imagery using RPC georeferencing that also sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF.

By default GDAL would assume that the imagery has zero elevation - if that is not the case, the image would not be shown in the correct location.

Since
QGIS 3.14

Definition at line 434 of file qgsgdalutils.cpp.

◆ rpcAwareCreateTransformer()

void * QgsGdalUtils::rpcAwareCreateTransformer ( GDALDatasetH  hSrcDS,
GDALDatasetH  hDstDS = nullptr,
char **  papszOptions = nullptr 
)
static

This is a wrapper around GDALCreateGenImgProjTransformer2() that takes into account RPC georeferencing (it sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF).

By default GDAL would assume that the imagery has zero elevation - if that is not the case, the image would not be shown in the correct location.

Since
QGIS 3.16

Definition at line 454 of file qgsgdalutils.cpp.

◆ setupProxy()

void QgsGdalUtils::setupProxy ( )
static

Sets the gdal proxy variables.

Definition at line 470 of file qgsgdalutils.cpp.

◆ supportsRasterCreate()

bool QgsGdalUtils::supportsRasterCreate ( GDALDriverH  driver)
static

Reads whether a driver supports GDALCreate() for raster purposes.

Parameters
driverGDAL driver
Returns
true if a driver supports GDALCreate() for raster purposes.

Definition at line 30 of file qgsgdalutils.cpp.

◆ validateCreationOptionsFormat()

QString QgsGdalUtils::validateCreationOptionsFormat ( const QStringList &  createOptions,
const QString &  format 
)
static

Validates creation options for a given format, regardless of layer.

Since
QGIS 3.10

Definition at line 276 of file qgsgdalutils.cpp.

Friends And Related Function Documentation

◆ TestQgsGdalUtils

friend class TestQgsGdalUtils
friend

Definition at line 135 of file qgsgdalutils.h.


The documentation for this class was generated from the following files: