QGIS API Documentation  2.99.0-Master (a411669)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsRasterFileWriter Class Reference

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

#include <qgsrasterfilewriter.h>

Public Types

enum  Mode { Raw = 0, Image = 1 }
 
enum  WriterError {
  NoError = 0, SourceProviderError = 1, DestProviderError = 2, CreateDatasourceError = 3,
  WriteError = 4, NoDataConflict = 5, WriteCanceled = 6
}
 

Public Member Functions

 QgsRasterFileWriter (const QString &outputUrl)
 
QgsRaster::RasterBuildPyramids buildPyramidsFlag () const
 
QgsRasterDataProvidercreateMultiBandRaster (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. More...
 
QgsRasterDataProvidercreateOneBandRaster (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. More...
 
QStringList createOptions () const
 
int maxTileHeight () const
 
int maxTileWidth () const
 
QString outputFormat () const
 
QString outputProviderKey () const
 
QString outputUrl () const
 Returns the output URL for the raster. More...
 
QStringList pyramidsConfigOptions () const
 
QgsRaster::RasterPyramidsFormat pyramidsFormat () const
 
QList< int > pyramidsList () const
 
QString pyramidsResampling () const
 
void setBuildPyramidsFlag (QgsRaster::RasterBuildPyramids f)
 
void setCreateOptions (const QStringList &list)
 
void setMaxTileHeight (int h)
 
void setMaxTileWidth (int w)
 
void setOutputFormat (const QString &format)
 
void setOutputProviderKey (const QString &key)
 
void setPyramidsConfigOptions (const QStringList &list)
 
void setPyramidsFormat (QgsRaster::RasterPyramidsFormat f)
 
void setPyramidsList (const QList< int > &list)
 
void setPyramidsResampling (const QString &str)
 
void setTiledMode (bool t)
 
bool tiledMode () const
 
WriterError writeRaster (const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QgsRasterBlockFeedback *feedback=nullptr)
 Write raster file. More...
 

Static Public Member Functions

static QString driverForExtension (const QString &extension)
 Returns the GDAL driver name for a specified file extension. More...
 

Detailed Description

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

Definition at line 38 of file qgsrasterfilewriter.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Raw 

Raw data.

Image 

Rendered image.

Definition at line 41 of file qgsrasterfilewriter.h.

◆ WriterError

Enumerator
NoError 
SourceProviderError 
DestProviderError 
CreateDatasourceError 
WriteError 
NoDataConflict 

Internal error if a value used for 'no data' was found in input.

WriteCanceled 

Writing was manually canceled.

Definition at line 46 of file qgsrasterfilewriter.h.

Constructor & Destructor Documentation

◆ QgsRasterFileWriter()

QgsRasterFileWriter::QgsRasterFileWriter ( const QString &  outputUrl)

Definition at line 59 of file qgsrasterfilewriter.cpp.

Member Function Documentation

◆ buildPyramidsFlag()

QgsRaster::RasterBuildPyramids QgsRasterFileWriter::buildPyramidsFlag ( ) const
inline

Definition at line 116 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.

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

Definition at line 47 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.

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

Definition at line 35 of file qgsrasterfilewriter.cpp.

◆ createOptions()

QStringList QgsRasterFileWriter::createOptions ( ) const
inline

Definition at line 132 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.

Since
QGIS 3.0

Definition at line 979 of file qgsrasterfilewriter.cpp.

◆ maxTileHeight()

int QgsRasterFileWriter::maxTileHeight ( ) const
inline

Definition at line 129 of file qgsrasterfilewriter.h.

◆ maxTileWidth()

int QgsRasterFileWriter::maxTileWidth ( ) const
inline

Definition at line 114 of file qgsrasterfilewriter.h.

◆ outputFormat()

QString QgsRasterFileWriter::outputFormat ( ) const
inline

Definition at line 105 of file qgsrasterfilewriter.h.

◆ outputProviderKey()

QString QgsRasterFileWriter::outputProviderKey ( ) const
inline

Definition at line 108 of file qgsrasterfilewriter.h.

◆ outputUrl()

QString QgsRasterFileWriter::outputUrl ( ) const
inline

Returns the output URL for the raster.

Since
QGIS 3.0

Definition at line 102 of file qgsrasterfilewriter.h.

◆ pyramidsConfigOptions()

QStringList QgsRasterFileWriter::pyramidsConfigOptions ( ) const
inline

Definition at line 135 of file qgsrasterfilewriter.h.

◆ pyramidsFormat()

QgsRaster::RasterPyramidsFormat QgsRasterFileWriter::pyramidsFormat ( ) const
inline

Definition at line 125 of file qgsrasterfilewriter.h.

◆ pyramidsList()

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

Definition at line 119 of file qgsrasterfilewriter.h.

◆ pyramidsResampling()

QString QgsRasterFileWriter::pyramidsResampling ( ) const
inline

Definition at line 122 of file qgsrasterfilewriter.h.

◆ setBuildPyramidsFlag()

void QgsRasterFileWriter::setBuildPyramidsFlag ( QgsRaster::RasterBuildPyramids  f)
inline

Definition at line 117 of file qgsrasterfilewriter.h.

◆ setCreateOptions()

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

Definition at line 131 of file qgsrasterfilewriter.h.

◆ setMaxTileHeight()

void QgsRasterFileWriter::setMaxTileHeight ( int  h)
inline

Definition at line 128 of file qgsrasterfilewriter.h.

◆ setMaxTileWidth()

void QgsRasterFileWriter::setMaxTileWidth ( int  w)
inline

Definition at line 113 of file qgsrasterfilewriter.h.

◆ setOutputFormat()

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

Definition at line 104 of file qgsrasterfilewriter.h.

◆ setOutputProviderKey()

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

Definition at line 107 of file qgsrasterfilewriter.h.

◆ setPyramidsConfigOptions()

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

Definition at line 134 of file qgsrasterfilewriter.h.

◆ setPyramidsFormat()

void QgsRasterFileWriter::setPyramidsFormat ( QgsRaster::RasterPyramidsFormat  f)
inline

Definition at line 126 of file qgsrasterfilewriter.h.

◆ setPyramidsList()

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

Definition at line 120 of file qgsrasterfilewriter.h.

◆ setPyramidsResampling()

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

Definition at line 123 of file qgsrasterfilewriter.h.

◆ setTiledMode()

void QgsRasterFileWriter::setTiledMode ( bool  t)
inline

Definition at line 110 of file qgsrasterfilewriter.h.

◆ tiledMode()

bool QgsRasterFileWriter::tiledMode ( ) const
inline

Definition at line 111 of file qgsrasterfilewriter.h.

◆ writeRaster()

QgsRasterFileWriter::WriterError 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

Definition at line 74 of file qgsrasterfilewriter.cpp.


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