QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
QgsRasterFileWriter Class Reference

The raster file writer which allows you to save a raster to a new file. More...

#include <qgsrasterfilewriter.h>

Classes

struct  FilterFormatDetails
 Details of available filters and formats. More...

Public Types

typedef QFlags< RasterFormatOption > RasterFormatOptions

Public Member Functions

 QgsRasterFileWriter (const QString &outputUrl)
 Constructor for QgsRasterFileWriter, writing to the specified output URL/filename.
Qgis::RasterBuildPyramidOption buildPyramidsFlag () const
 Returns the pyramid building option.
QgsRasterDataProvidercreateMultiBandRaster (Qgis::DataType dataType, int width, int height, const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs, int nBands) SIP_FACTORY
 Create a raster file with given number of bands without initializing the pixel data.
QgsRasterDataProvidercreateOneBandRaster (Qgis::DataType dataType, int width, int height, const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs) SIP_FACTORY
 Create a raster file with one band without initializing the pixel data.
Q_DECL_DEPRECATED QStringList createOptions () const SIP_DEPRECATED
 Returns the list of data source creation options which will be used when creating the output raster file.
QStringList creationOptions () const
 Returns the list of data source creation options which will be used when creating the output raster file.
int maxTileHeight () const
 Returns the maximum tile height (in pixels) for tiled outputs.
int maxTileWidth () const
 Returns the maximum tile width (in pixels) for tiled outputs.
QString outputFormat () const
 Returns the output format.
QString outputProviderKey () const
 Returns the name of the data provider for the raster output.
QString outputUrl () const
 Returns the output URL (filename) for the raster.
QStringList pyramidsConfigOptions () const
 Returns the list of configuration options used when creating the pyramids for the output raster file.
Qgis::RasterPyramidFormat pyramidsFormat () const
 Returns the raster pyramid format.
QList< int > pyramidsList () const
 Returns the list of pyramids which will be created for the output file.
QString pyramidsResampling () const
void setBuildPyramidsFlag (Qgis::RasterBuildPyramidOption f)
 Sets the pyramid building option.
Q_DECL_DEPRECATED void setCreateOptions (const QStringList &list) SIP_DEPRECATED
 Sets a list of data source creation options to use when creating the output raster file.
void setCreationOptions (const QStringList &options)
 Sets a list of data source creation options to use when creating the output raster file.
void setMaxTileHeight (int h)
 Sets the maximum tile height (in pixels) for tiled outputs.
void setMaxTileWidth (int w)
 Sets the maximum tile width (in pixels) for tiled outputs.
void setOutputFormat (const QString &format)
 Sets the output format.
void setOutputProviderKey (const QString &key)
 Sets the name of the data provider for the raster output.
void setPyramidsConfigOptions (const QStringList &list)
 Sets a list of configuration options to use when creating the pyramids for the output raster file.
void setPyramidsFormat (Qgis::RasterPyramidFormat f)
 Sets the raster pyramid format.
void setPyramidsList (const QList< int > &list)
 Sets the list of pyramids which will be created for the output file.
void setPyramidsResampling (const QString &str)
void setTiledMode (bool t)
 Sets whether the output should be tiled.
enum RasterFormatOption SIP_ENUM_BASETYPE (IntFlag)
 Options for sorting and filtering raster formats.
bool tiledMode () const
 Returns whether the output will be tiled.
Qgis::RasterFileWriterResult writeRaster (const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext, QgsRasterBlockFeedback *feedback=nullptr)
 Write raster file.
Q_DECL_DEPRECATED Qgis::RasterFileWriterResult writeRaster (const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QgsRasterBlockFeedback *feedback=nullptr) SIP_DEPRECATED
 Write raster file.

Static Public Member Functions

static QString driverForExtension (const QString &extension)
 Returns the GDAL driver name for a specified file extension.
static QStringList extensionsForFormat (const QString &format)
 Returns a list of known file extensions for the given GDAL driver format.
static QString filterForDriver (const QString &driverName)
 Creates a filter for an GDAL driver key.
static QList< QgsRasterFileWriter::FilterFormatDetailssupportedFiltersAndFormats (RasterFormatOptions options=SortRecommended)
 Returns a list or pairs, with format filter string as first element and GDAL format key as second element.
static QStringList supportedFormatExtensions (RasterFormatOptions options=SortRecommended)
 Returns a list of file extensions for supported formats.

Detailed Description

The raster file writer which allows you to save a raster to a new file.

The writer defaults to creating GeoTIFF outputs using GDAL. Alternative formats and data providers can be used by calling setOutputFormat() and setOutputProviderKey().

Definition at line 41 of file qgsrasterfilewriter.h.

Member Typedef Documentation

◆ RasterFormatOptions

typedef QFlags< RasterFormatOption > QgsRasterFileWriter::RasterFormatOptions

Definition at line 52 of file qgsrasterfilewriter.h.

Constructor & Destructor Documentation

◆ QgsRasterFileWriter()

QgsRasterFileWriter::QgsRasterFileWriter ( const QString & outputUrl)

Constructor for QgsRasterFileWriter, writing to the specified output URL/filename.

Definition at line 65 of file qgsrasterfilewriter.cpp.

Member Function Documentation

◆ buildPyramidsFlag()

Qgis::RasterBuildPyramidOption QgsRasterFileWriter::buildPyramidsFlag ( ) const
inline

Returns the pyramid building option.

See also
setBuildPyramidsFlag()

Definition at line 193 of file qgsrasterfilewriter.h.

◆ createMultiBandRaster()

QgsRasterDataProvider * QgsRasterFileWriter::createMultiBandRaster ( Qgis::DataType dataType,
int width,
int height,
const QgsRectangle & extent,
const QgsCoordinateReferenceSystem & crs,
int nBands )

Create a raster file with given number of bands without initializing the pixel data.

Returned provider may be used to initialize the raster using writeBlock() calls. Ownership of the returned provider is passed to the caller.

Returns
Instance of data provider in editing mode (on success) or nullptr on error.
Note
Does not work with tiled mode enabled.

Definition at line 53 of file qgsrasterfilewriter.cpp.

◆ createOneBandRaster()

QgsRasterDataProvider * QgsRasterFileWriter::createOneBandRaster ( Qgis::DataType dataType,
int width,
int height,
const QgsRectangle & extent,
const QgsCoordinateReferenceSystem & crs )

Create a raster file with one band without initializing the pixel data.

Returned provider may be used to initialize the raster using writeBlock() calls. Ownership of the returned provider is passed to the caller.

Returns
Instance of data provider in editing mode (on success) or nullptr on error.
Note
Does not work with tiled mode enabled.

Definition at line 41 of file qgsrasterfilewriter.cpp.

◆ createOptions()

Q_DECL_DEPRECATED QStringList QgsRasterFileWriter::createOptions ( ) const
inline

Returns the list of data source creation options which will be used when creating the output raster file.

See also
setCreateOptions()
Deprecated
QGIS 3.44. Use creationOptions() instead.

Definition at line 269 of file qgsrasterfilewriter.h.

◆ creationOptions()

QStringList QgsRasterFileWriter::creationOptions ( ) const
inline

Returns the list of data source creation options which will be used when creating the output raster file.

See also
setCreationOptions()
Since
QGIS 3.44

Definition at line 278 of file qgsrasterfilewriter.h.

◆ driverForExtension()

QString QgsRasterFileWriter::driverForExtension ( const QString & extension)
static

Returns the GDAL driver name for a specified file extension.

E.g. the driver name for the ".tif" extension is "GTiff". If no suitable drivers are found then an empty string is returned.

Note that this method works for all GDAL drivers, including those without create support (and which are not supported by QgsRasterFileWriter).

Definition at line 1065 of file qgsrasterfilewriter.cpp.

◆ extensionsForFormat()

QStringList QgsRasterFileWriter::extensionsForFormat ( const QString & format)
static

Returns a list of known file extensions for the given GDAL driver format.

E.g. returns "tif", "tiff" for the format "GTiff".

If no matching format driver is found an empty list will be returned.

Note that this method works for all GDAL drivers, including those without create support (and which are not supported by QgsRasterFileWriter).

Definition at line 1110 of file qgsrasterfilewriter.cpp.

◆ filterForDriver()

QString QgsRasterFileWriter::filterForDriver ( const QString & driverName)
static

Creates a filter for an GDAL driver key.

Definition at line 1124 of file qgsrasterfilewriter.cpp.

◆ maxTileHeight()

int QgsRasterFileWriter::maxTileHeight ( ) const
inline

Returns the maximum tile height (in pixels) for tiled outputs.

See also
maxTileWidth()
setMaxTileHeight()
tiledMode()

Definition at line 249 of file qgsrasterfilewriter.h.

◆ maxTileWidth()

int QgsRasterFileWriter::maxTileWidth ( ) const
inline

Returns the maximum tile width (in pixels) for tiled outputs.

See also
maxTileHeight()
setMaxTileWidth()
tiledMode()

Definition at line 186 of file qgsrasterfilewriter.h.

◆ outputFormat()

QString QgsRasterFileWriter::outputFormat ( ) const
inline

Returns the output format.

For GDAL disk based outputs this will match the GDAL driver name, e.g. "GTiff" for GeoTiff exports.

See also
setOutputFormat()

Definition at line 135 of file qgsrasterfilewriter.h.

◆ outputProviderKey()

QString QgsRasterFileWriter::outputProviderKey ( ) const
inline

Returns the name of the data provider for the raster output.

See also
setOutputProviderKey()

Definition at line 151 of file qgsrasterfilewriter.h.

◆ outputUrl()

QString QgsRasterFileWriter::outputUrl ( ) const
inline

Returns the output URL (filename) for the raster.

Definition at line 117 of file qgsrasterfilewriter.h.

◆ pyramidsConfigOptions()

QStringList QgsRasterFileWriter::pyramidsConfigOptions ( ) const
inline

Returns the list of configuration options used when creating the pyramids for the output raster file.

See also
setPyramidsConfigOptions()

Definition at line 305 of file qgsrasterfilewriter.h.

◆ pyramidsFormat()

Qgis::RasterPyramidFormat QgsRasterFileWriter::pyramidsFormat ( ) const
inline

Returns the raster pyramid format.

See also
setPyramidsFormat()

Definition at line 224 of file qgsrasterfilewriter.h.

◆ pyramidsList()

QList< int > QgsRasterFileWriter::pyramidsList ( ) const
inline

Returns the list of pyramids which will be created for the output file.

See also
setPyramidsList()

Definition at line 207 of file qgsrasterfilewriter.h.

◆ pyramidsResampling()

QString QgsRasterFileWriter::pyramidsResampling ( ) const
inline

Definition at line 216 of file qgsrasterfilewriter.h.

◆ setBuildPyramidsFlag()

void QgsRasterFileWriter::setBuildPyramidsFlag ( Qgis::RasterBuildPyramidOption f)
inline

Sets the pyramid building option.

See also
buildPyramidsFlag()

Definition at line 200 of file qgsrasterfilewriter.h.

◆ setCreateOptions()

Q_DECL_DEPRECATED void QgsRasterFileWriter::setCreateOptions ( const QStringList & list)
inline

Sets a list of data source creation options to use when creating the output raster file.

See also
createOptions()
Deprecated
QGIS 3.44. Use setCreationOptions() instead.

Definition at line 260 of file qgsrasterfilewriter.h.

◆ setCreationOptions()

void QgsRasterFileWriter::setCreationOptions ( const QStringList & options)
inline

Sets a list of data source creation options to use when creating the output raster file.

See also
creationOptions()
Since
QGIS 3.44

Definition at line 287 of file qgsrasterfilewriter.h.

◆ setMaxTileHeight()

void QgsRasterFileWriter::setMaxTileHeight ( int h)
inline

Sets the maximum tile height (in pixels) for tiled outputs.

See also
maxTileHeight()
setMaxTileWidth()
tiledMode()

Definition at line 240 of file qgsrasterfilewriter.h.

◆ setMaxTileWidth()

void QgsRasterFileWriter::setMaxTileWidth ( int w)
inline

Sets the maximum tile width (in pixels) for tiled outputs.

See also
maxTileWidth()
setMaxTileHeight()
tiledMode()

Definition at line 177 of file qgsrasterfilewriter.h.

◆ setOutputFormat()

void QgsRasterFileWriter::setOutputFormat ( const QString & format)
inline

Sets the output format.

For GDAL disk based outputs this should match the GDAL driver name, e.g. "GTiff" for GeoTiff exports.

See also
outputFormat()

Definition at line 126 of file qgsrasterfilewriter.h.

◆ setOutputProviderKey()

void QgsRasterFileWriter::setOutputProviderKey ( const QString & key)
inline

Sets the name of the data provider for the raster output.

E.g. set to "gdal" to use GDAL to create disk based raster files.

See also
outputProviderKey()

Definition at line 144 of file qgsrasterfilewriter.h.

◆ setPyramidsConfigOptions()

void QgsRasterFileWriter::setPyramidsConfigOptions ( const QStringList & list)
inline

Sets a list of configuration options to use when creating the pyramids for the output raster file.

See also
pyramidsConfigOptions()

Definition at line 297 of file qgsrasterfilewriter.h.

◆ setPyramidsFormat()

void QgsRasterFileWriter::setPyramidsFormat ( Qgis::RasterPyramidFormat f)
inline

Sets the raster pyramid format.

See also
pyramidsFormat()

Definition at line 231 of file qgsrasterfilewriter.h.

◆ setPyramidsList()

void QgsRasterFileWriter::setPyramidsList ( const QList< int > & list)
inline

Sets the list of pyramids which will be created for the output file.

See also
pyramidsList()

Definition at line 214 of file qgsrasterfilewriter.h.

◆ setPyramidsResampling()

void QgsRasterFileWriter::setPyramidsResampling ( const QString & str)
inline

Definition at line 217 of file qgsrasterfilewriter.h.

◆ setTiledMode()

void QgsRasterFileWriter::setTiledMode ( bool t)
inline

Sets whether the output should be tiled.

Tiled outputs will automatically split the raster into multiple parts, based on the maxTileWidth() value.

See also
tiledMode()

Definition at line 161 of file qgsrasterfilewriter.h.

◆ SIP_ENUM_BASETYPE()

enum RasterFormatOption QgsRasterFileWriter::SIP_ENUM_BASETYPE ( IntFlag )
inline

Options for sorting and filtering raster formats.

< Use recommended sort order, with extremely commonly used formats listed first

Definition at line 48 of file qgsrasterfilewriter.h.

◆ supportedFiltersAndFormats()

QList< QgsRasterFileWriter::FilterFormatDetails > QgsRasterFileWriter::supportedFiltersAndFormats ( RasterFormatOptions options = SortRecommended)
static

Returns a list or pairs, with format filter string as first element and GDAL format key as second element.

Relies on GDAL_DMD_EXTENSIONS metadata, if it is empty corresponding driver will be skipped even if supported.

The options argument can be used to control the sorting and filtering of returned formats.

See also
supportedFormatExtensions()

Definition at line 1148 of file qgsrasterfilewriter.cpp.

◆ supportedFormatExtensions()

QStringList QgsRasterFileWriter::supportedFormatExtensions ( RasterFormatOptions options = SortRecommended)
static

Returns a list of file extensions for supported formats.

The options argument can be used to control the sorting and filtering of returned formats.

See also
supportedFiltersAndFormats()

Definition at line 1215 of file qgsrasterfilewriter.cpp.

◆ tiledMode()

bool QgsRasterFileWriter::tiledMode ( ) const
inline

Returns whether the output will be tiled.

See also
setTiledMode()

Definition at line 168 of file qgsrasterfilewriter.h.

◆ writeRaster() [1/2]

Qgis::RasterFileWriterResult QgsRasterFileWriter::writeRaster ( const QgsRasterPipe * pipe,
int nCols,
int nRows,
const QgsRectangle & outputExtent,
const QgsCoordinateReferenceSystem & crs,
const QgsCoordinateTransformContext & transformContext,
QgsRasterBlockFeedback * feedback = nullptr )

Write raster file.

Parameters
piperaster pipe
nColsnumber of output columns
nRowsnumber of output rows (or -1 to automatically calculate row number to have square pixels)
outputExtentextent to output
crscrs to reproject to
transformContextcoordinate transform context
feedbackoptional feedback object for progress reports
Since
QGIS 3.8

Definition at line 84 of file qgsrasterfilewriter.cpp.

◆ writeRaster() [2/2]

Qgis::RasterFileWriterResult QgsRasterFileWriter::writeRaster ( const QgsRasterPipe * pipe,
int nCols,
int nRows,
const QgsRectangle & outputExtent,
const QgsCoordinateReferenceSystem & crs,
QgsRasterBlockFeedback * feedback = nullptr )

Write raster file.

Parameters
piperaster pipe
nColsnumber of output columns
nRowsnumber of output rows (or -1 to automatically calculate row number to have square pixels)
outputExtentextent to output
crscrs to reproject to
feedbackoptional feedback object for progress reports
Deprecated
QGIS 3.8. Use version with transformContext instead.

Definition at line 78 of file qgsrasterfilewriter.cpp.


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