QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | 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>

Collaboration diagram for QgsRasterFileWriter:
Collaboration graph
[legend]

Public Types

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

Public Member Functions

 QgsRasterFileWriter (const QString &outputUrl)
 ~QgsRasterFileWriter ()
WriterError writeRaster (const QgsRasterPipe *pipe, int nCols, int nRows, QgsRectangle outputExtent, const QgsCoordinateReferenceSystem &crs, QProgressDialog *p=0)
 Write raster file.
void setOutputFormat (const QString &format)
QString outputFormat () const
void setOutputProviderKey (const QString &key)
QString outputProviderKey () const
void setTiledMode (bool t)
bool tiledMode () const
void setMaxTileWidth (int w)
int maxTileWidth () const
QgsRaster::RasterBuildPyramids buildPyramidsFlag () const
void setBuildPyramidsFlag (QgsRaster::RasterBuildPyramids f)
QList< int > pyramidsList () const
void setPyramidsList (const QList< int > &list)
QString pyramidsResampling () const
void setPyramidsResampling (const QString &str)
QgsRaster::RasterPyramidsFormat pyramidsFormat () const
void setPyramidsFormat (QgsRaster::RasterPyramidsFormat f)
void setMaxTileHeight (int h)
int maxTileHeight () const
void setCreateOptions (const QStringList &list)
QStringList createOptions () const
void setPyramidsConfigOptions (const QStringList &list)
QStringList pyramidsConfigOptions () const

Private Member Functions

 QgsRasterFileWriter ()
WriterError writeDataRaster (const QgsRasterPipe *pipe, QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QProgressDialog *progressDialog=0)
WriterError writeDataRaster (const QgsRasterPipe *pipe, QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QGis::DataType destDataType, QList< bool > destHasNoDataValueList, QList< double > destNoDataValueList, QgsRasterDataProvider *destProvider, QProgressDialog *progressDialog)
WriterError writeImageRaster (QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QProgressDialog *progressDialog=0)
void createVRT (int xSize, int ySize, const QgsCoordinateReferenceSystem &crs, double *geoTransform, QGis::DataType type, QList< bool > destHasNoDataValueList, QList< double > destNoDataValueList)
 Initialize vrt member variables.
bool writeVRT (const QString &file)
void addToVRT (const QString &filename, int band, int xSize, int ySize, int xOffset, int yOffset)
void buildPyramids (const QString &filename)
QgsRasterDataProvidercreatePartProvider (const QgsRectangle &extent, int nCols, int iterCols, int iterRows, int iterLeft, int iterTop, const QString &outputUrl, int fileIndex, int nBands, QGis::DataType type, const QgsCoordinateReferenceSystem &crs)
 Create provider and datasource for a part image (vrt mode)
QgsRasterDataProviderinitOutput (int nCols, int nRows, const QgsCoordinateReferenceSystem &crs, double *geoTransform, int nBands, QGis::DataType type, QList< bool > destHasNoDataValueList=QList< bool >(), QList< double > destNoDataValueList=QList< double >())
 Init VRT (for tiled mode) or create global output provider (single-file mode)
void globalOutputParameters (const QgsRectangle &extent, int nCols, int &nRows, double *geoTransform, double &pixelSize)
 Calculate nRows, geotransform and pixel size for output.
QString partFileName (int fileIndex)
QString vrtFileName ()

Private Attributes

Mode mMode
QString mOutputUrl
QString mOutputProviderKey
QString mOutputFormat
QStringList mCreateOptions
QgsCoordinateReferenceSystem mOutputCRS
bool mTiledMode
 False: Write one file, true: create a directory and add the files numbered.
double mMaxTileWidth
double mMaxTileHeight
QList< int > mPyramidsList
QString mPyramidsResampling
QgsRaster::RasterBuildPyramids mBuildPyramidsFlag
QgsRaster::RasterPyramidsFormat mPyramidsFormat
QStringList mPyramidsConfigOptions
QDomDocument mVRTDocument
QList< QDomElement > mVRTBands
QProgressDialog * mProgressDialog
const QgsRasterPipemPipe
const QgsRasterInterfacemInput

Detailed Description

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

Definition at line 32 of file qgsrasterfilewriter.h.

Member Enumeration Documentation

Enumerator:
Raw 
Image 

Definition at line 35 of file qgsrasterfilewriter.h.

Enumerator:
NoError 
SourceProviderError 
DestProviderError 
CreateDatasourceError 
WriteError 
NoDataConflict 

Definition at line 40 of file qgsrasterfilewriter.h.

Constructor & Destructor Documentation

QgsRasterFileWriter::QgsRasterFileWriter ( const QString &  outputUrl)

Definition at line 29 of file qgsrasterfilewriter.cpp.

QgsRasterFileWriter::~QgsRasterFileWriter ( )

Definition at line 44 of file qgsrasterfilewriter.cpp.

QgsRasterFileWriter::QgsRasterFileWriter ( )
private

Definition at line 39 of file qgsrasterfilewriter.cpp.

Member Function Documentation

void QgsRasterFileWriter::addToVRT ( const QString &  filename,
int  band,
int  xSize,
int  ySize,
int  xOffset,
int  yOffset 
)
private

Definition at line 608 of file qgsrasterfilewriter.cpp.

References mVRTBands, and mVRTDocument.

Referenced by writeDataRaster(), and writeImageRaster().

void QgsRasterFileWriter::buildPyramids ( const QString &  filename)
private
QgsRaster::RasterBuildPyramids QgsRasterFileWriter::buildPyramidsFlag ( ) const
inline

Definition at line 76 of file qgsrasterfilewriter.h.

QStringList QgsRasterFileWriter::createOptions ( ) const
inline

Definition at line 92 of file qgsrasterfilewriter.h.

QgsRasterDataProvider * QgsRasterFileWriter::createPartProvider ( const QgsRectangle extent,
int  nCols,
int  iterCols,
int  iterRows,
int  iterLeft,
int  iterTop,
const QString &  outputUrl,
int  fileIndex,
int  nBands,
QGis::DataType  type,
const QgsCoordinateReferenceSystem crs 
)
private
void QgsRasterFileWriter::createVRT ( int  xSize,
int  ySize,
const QgsCoordinateReferenceSystem crs,
double *  geoTransform,
QGis::DataType  type,
QList< bool >  destHasNoDataValueList,
QList< double >  destNoDataValueList 
)
private

Initialize vrt member variables.

Parameters
xSizewidth of vrt
ySizeheight of vrt
crscoordinate system of vrt
geoTransformoptional array of transformation matrix values
typedatatype of vrt
destHasNoDataValueListtrue if destination has no data value, indexed from 0
destNoDataValueListno data value, indexed from 0

Definition at line 771 of file qgsrasterfilewriter.cpp.

References QgsRasterInterface::bandCount(), QGis::Byte, QGis::CFloat32, QGis::CFloat64, QGis::CInt16, QGis::CInt32, QGis::Float32, QGis::Float64, Image, QGis::Int16, mInput, mMode, mVRTBands, mVRTDocument, Raw, QgsCoordinateReferenceSystem::toWkt(), QGis::UInt16, and QGis::UInt32.

Referenced by initOutput().

void QgsRasterFileWriter::globalOutputParameters ( const QgsRectangle extent,
int  nCols,
int &  nRows,
double *  geoTransform,
double &  pixelSize 
)
private

Calculate nRows, geotransform and pixel size for output.

Definition at line 922 of file qgsrasterfilewriter.cpp.

References QgsRectangle::height(), QgsRectangle::width(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().

Referenced by writeDataRaster(), and writeImageRaster().

QgsRasterDataProvider * QgsRasterFileWriter::initOutput ( int  nCols,
int  nRows,
const QgsCoordinateReferenceSystem crs,
double *  geoTransform,
int  nBands,
QGis::DataType  type,
QList< bool >  destHasNoDataValueList = QList<bool>(),
QList< double >  destNoDataValueList = QList<double>() 
)
private

Init VRT (for tiled mode) or create global output provider (single-file mode)

Parameters
nColsnumber of tile columns
nRowsnumber of tile rows
crscoordinate system of vrt
geoTransformoptional array of transformation matrix values
nBandsnumber of bands
typedatatype of vrt
destHasNoDataValueListtrue if destination has no data value, indexed from 0
destNoDataValueListno data value, indexed from 0

Definition at line 893 of file qgsrasterfilewriter.cpp.

References QgsRasterDataProvider::create(), createVRT(), mBuildPyramidsFlag, mCreateOptions, mOutputFormat, mOutputProviderKey, mOutputUrl, mTiledMode, and QgsDebugMsg.

Referenced by writeDataRaster(), and writeImageRaster().

int QgsRasterFileWriter::maxTileHeight ( ) const
inline

Definition at line 89 of file qgsrasterfilewriter.h.

int QgsRasterFileWriter::maxTileWidth ( ) const
inline

Definition at line 74 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::outputFormat ( ) const
inline

Definition at line 65 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::outputProviderKey ( ) const
inline

Definition at line 68 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::partFileName ( int  fileIndex)
private

Definition at line 940 of file qgsrasterfilewriter.cpp.

References mOutputUrl.

Referenced by createPartProvider(), writeDataRaster(), and writeImageRaster().

QStringList QgsRasterFileWriter::pyramidsConfigOptions ( ) const
inline

Definition at line 95 of file qgsrasterfilewriter.h.

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

Definition at line 85 of file qgsrasterfilewriter.h.

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

Definition at line 79 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::pyramidsResampling ( ) const
inline

Definition at line 82 of file qgsrasterfilewriter.h.

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

Definition at line 77 of file qgsrasterfilewriter.h.

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

Definition at line 91 of file qgsrasterfilewriter.h.

void QgsRasterFileWriter::setMaxTileHeight ( int  h)
inline

Definition at line 88 of file qgsrasterfilewriter.h.

void QgsRasterFileWriter::setMaxTileWidth ( int  w)
inline

Definition at line 73 of file qgsrasterfilewriter.h.

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

Definition at line 64 of file qgsrasterfilewriter.h.

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

Definition at line 67 of file qgsrasterfilewriter.h.

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

Definition at line 94 of file qgsrasterfilewriter.h.

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

Definition at line 86 of file qgsrasterfilewriter.h.

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

Definition at line 80 of file qgsrasterfilewriter.h.

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

Definition at line 83 of file qgsrasterfilewriter.h.

void QgsRasterFileWriter::setTiledMode ( bool  t)
inline

Definition at line 70 of file qgsrasterfilewriter.h.

bool QgsRasterFileWriter::tiledMode ( ) const
inline

Definition at line 71 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::vrtFileName ( )
private

Definition at line 947 of file qgsrasterfilewriter.cpp.

References mOutputUrl.

Referenced by writeDataRaster(), and writeImageRaster().

QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeDataRaster ( const QgsRasterPipe pipe,
QgsRasterIterator iter,
int  nCols,
int  nRows,
const QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem crs,
QProgressDialog *  progressDialog = 0 
)
private
QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeDataRaster ( const QgsRasterPipe pipe,
QgsRasterIterator iter,
int  nCols,
int  nRows,
const QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem crs,
QGis::DataType  destDataType,
QList< bool >  destHasNoDataValueList,
QList< double >  destNoDataValueList,
QgsRasterDataProvider destProvider,
QProgressDialog *  progressDialog 
)
private
QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeImageRaster ( QgsRasterIterator iter,
int  nCols,
int  nRows,
const QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem crs,
QProgressDialog *  progressDialog = 0 
)
private
QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster ( const QgsRasterPipe pipe,
int  nCols,
int  nRows,
QgsRectangle  outputExtent,
const QgsCoordinateReferenceSystem crs,
QProgressDialog *  p = 0 
)

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
pdialog to show progress in

Definition at line 49 of file qgsrasterfilewriter.cpp.

References CreateDatasourceError, QgsRasterInterface::dataType(), Image, QgsRasterPipe::last(), mInput, mMode, mOutputUrl, mPipe, mProgressDialog, mTiledMode, QgsDebugMsg, Raw, SourceProviderError, QgsRasterInterface::srcInput(), QgsRasterBlock::typeIsColor(), writeDataRaster(), and writeImageRaster().

bool QgsRasterFileWriter::writeVRT ( const QString &  file)
private

Definition at line 850 of file qgsrasterfilewriter.cpp.

References mVRTDocument.

Referenced by writeDataRaster(), and writeImageRaster().

Member Data Documentation

QgsRaster::RasterBuildPyramids QgsRasterFileWriter::mBuildPyramidsFlag
private

Definition at line 174 of file qgsrasterfilewriter.h.

Referenced by initOutput(), writeDataRaster(), and writeImageRaster().

QStringList QgsRasterFileWriter::mCreateOptions
private

Definition at line 164 of file qgsrasterfilewriter.h.

Referenced by createPartProvider(), and initOutput().

const QgsRasterInterface* QgsRasterFileWriter::mInput
private

Definition at line 184 of file qgsrasterfilewriter.h.

Referenced by createVRT(), and writeRaster().

double QgsRasterFileWriter::mMaxTileHeight
private

Definition at line 170 of file qgsrasterfilewriter.h.

Referenced by writeDataRaster(), and writeImageRaster().

double QgsRasterFileWriter::mMaxTileWidth
private

Definition at line 169 of file qgsrasterfilewriter.h.

Referenced by writeDataRaster(), and writeImageRaster().

Mode QgsRasterFileWriter::mMode
private

Definition at line 160 of file qgsrasterfilewriter.h.

Referenced by createVRT(), and writeRaster().

QgsCoordinateReferenceSystem QgsRasterFileWriter::mOutputCRS
private

Definition at line 165 of file qgsrasterfilewriter.h.

QString QgsRasterFileWriter::mOutputFormat
private

Definition at line 163 of file qgsrasterfilewriter.h.

Referenced by createPartProvider(), and initOutput().

QString QgsRasterFileWriter::mOutputProviderKey
private

Definition at line 162 of file qgsrasterfilewriter.h.

Referenced by buildPyramids(), createPartProvider(), and initOutput().

QString QgsRasterFileWriter::mOutputUrl
private
const QgsRasterPipe* QgsRasterFileWriter::mPipe
private

Definition at line 183 of file qgsrasterfilewriter.h.

Referenced by writeRaster().

QProgressDialog* QgsRasterFileWriter::mProgressDialog
private

Definition at line 181 of file qgsrasterfilewriter.h.

Referenced by writeRaster().

QStringList QgsRasterFileWriter::mPyramidsConfigOptions
private

Definition at line 176 of file qgsrasterfilewriter.h.

Referenced by buildPyramids().

QgsRaster::RasterPyramidsFormat QgsRasterFileWriter::mPyramidsFormat
private

Definition at line 175 of file qgsrasterfilewriter.h.

Referenced by buildPyramids().

QList< int > QgsRasterFileWriter::mPyramidsList
private

Definition at line 172 of file qgsrasterfilewriter.h.

Referenced by buildPyramids().

QString QgsRasterFileWriter::mPyramidsResampling
private

Definition at line 173 of file qgsrasterfilewriter.h.

Referenced by buildPyramids().

bool QgsRasterFileWriter::mTiledMode
private

False: Write one file, true: create a directory and add the files numbered.

Definition at line 168 of file qgsrasterfilewriter.h.

Referenced by initOutput(), writeDataRaster(), writeImageRaster(), and writeRaster().

QList<QDomElement> QgsRasterFileWriter::mVRTBands
private

Definition at line 179 of file qgsrasterfilewriter.h.

Referenced by addToVRT(), and createVRT().

QDomDocument QgsRasterFileWriter::mVRTDocument
private

Definition at line 178 of file qgsrasterfilewriter.h.

Referenced by addToVRT(), createVRT(), and writeVRT().


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