QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsrasterfilewriter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterfilewriter.h
3 ---------------------
4 begin : July 2012
5 copyright : (C) 2012 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSRASTERFILEWRITER_H
16#define QGSRASTERFILEWRITER_H
17
18#include "qgis_core.h"
21#include <QDomDocument>
22#include <QDomElement>
23#include <QString>
24#include <QStringList>
25
28class QgsRasterPipe;
29class QgsRectangle;
32
40class CORE_EXPORT QgsRasterFileWriter
41{
42 public:
43
47 enum RasterFormatOption SIP_ENUM_BASETYPE( IntFlag )
48 {
49 SortRecommended = 1 << 1,
50 };
51 Q_DECLARE_FLAGS( RasterFormatOptions, RasterFormatOption )
52
53
56 QgsRasterFileWriter( const QString &outputUrl );
57
65 QgsRasterDataProvider *createOneBandRaster( Qgis::DataType dataType,
66 int width, int height,
67 const QgsRectangle &extent,
69
77 QgsRasterDataProvider *createMultiBandRaster( Qgis::DataType dataType,
78 int width, int height,
79 const QgsRectangle &extent,
81 int nBands ) SIP_FACTORY;
82
83
94 Q_DECL_DEPRECATED Qgis::RasterFileWriterResult writeRaster( const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent,
96
108 Qgis::RasterFileWriterResult writeRaster( const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent,
110 const QgsCoordinateTransformContext &transformContext,
111 QgsRasterBlockFeedback *feedback = nullptr );
112
116 QString outputUrl() const { return mOutputUrl; }
117
125 void setOutputFormat( const QString &format ) { mOutputFormat = format; }
126
134 QString outputFormat() const { return mOutputFormat; }
135
143 void setOutputProviderKey( const QString &key ) { mOutputProviderKey = key; }
144
150 QString outputProviderKey() const { return mOutputProviderKey; }
151
160 void setTiledMode( bool t ) { mTiledMode = t; }
161
167 bool tiledMode() const { return mTiledMode; }
168
176 void setMaxTileWidth( int w ) { mMaxTileWidth = w; }
177
185 int maxTileWidth() const { return mMaxTileWidth; }
186
192 Qgis::RasterBuildPyramidOption buildPyramidsFlag() const { return mBuildPyramidsFlag; }
193
199 void setBuildPyramidsFlag( Qgis::RasterBuildPyramidOption f ) { mBuildPyramidsFlag = f; }
200
206 QList< int > pyramidsList() const { return mPyramidsList; }
207
213 void setPyramidsList( const QList< int > &list ) { mPyramidsList = list; }
214
215 QString pyramidsResampling() const { return mPyramidsResampling; }
216 void setPyramidsResampling( const QString &str ) { mPyramidsResampling = str; }
217
223 Qgis::RasterPyramidFormat pyramidsFormat() const { return mPyramidsFormat; }
224
230 void setPyramidsFormat( Qgis::RasterPyramidFormat f ) { mPyramidsFormat = f; }
231
239 void setMaxTileHeight( int h ) { mMaxTileHeight = h; }
240
248 int maxTileHeight() const { return mMaxTileHeight; }
249
256 void setCreateOptions( const QStringList &list ) { mCreateOptions = list; }
257
264 QStringList createOptions() const { return mCreateOptions; }
265
272 void setPyramidsConfigOptions( const QStringList &list ) { mPyramidsConfigOptions = list; }
273
280 QStringList pyramidsConfigOptions() const { return mPyramidsConfigOptions; }
281
283 static QString filterForDriver( const QString &driverName );
284
289 {
291 QString driverName;
292
295 };
296
306 static QList< QgsRasterFileWriter::FilterFormatDetails > supportedFiltersAndFormats( RasterFormatOptions options = SortRecommended );
307
316 static QStringList supportedFormatExtensions( RasterFormatOptions options = SortRecommended );
317
327 static QString driverForExtension( const QString &extension );
328
339 static QStringList extensionsForFormat( const QString &format );
340
341 private:
342 QgsRasterFileWriter(); //forbidden
343 Qgis::RasterFileWriterResult writeDataRaster( const QgsRasterPipe *pipe, QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent,
344 const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext,
345 QgsRasterBlockFeedback *feedback = nullptr );
346
347 // Helper method used by previous one
348 Qgis::RasterFileWriterResult writeDataRaster( const QgsRasterPipe *pipe,
349 QgsRasterIterator *iter,
350 int nCols, int nRows,
351 const QgsRectangle &outputExtent,
353 Qgis::DataType destDataType,
354 const QList<bool> &destHasNoDataValueList,
355 const QList<double> &destNoDataValueList,
356 QgsRasterDataProvider *destProvider,
357 QgsRasterBlockFeedback *feedback = nullptr );
358
359 Qgis::RasterFileWriterResult writeImageRaster( QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent,
361 QgsRasterBlockFeedback *feedback = nullptr );
362
373 void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem &crs, double *geoTransform, Qgis::DataType type, const QList<bool> &destHasNoDataValueList, const QList<double> &destNoDataValueList );
374 //write vrt document to disk
375 bool writeVRT( const QString &file );
376 //add file entry to vrt
377 void addToVRT( const QString &filename, int band, int xSize, int ySize, int xOffset, int yOffset );
378 void buildPyramids( const QString &filename, QgsRasterDataProvider *destProviderIn = nullptr );
379
381 QgsRasterDataProvider *createPartProvider( const QgsRectangle &extent, int nCols, int iterCols, int iterRows,
382 int iterLeft, int iterTop,
383 const QString &outputUrl, int fileIndex, int nBands, Qgis::DataType type,
385
397 QgsRasterDataProvider *initOutput( int nCols, int nRows,
398 const QgsCoordinateReferenceSystem &crs, double *geoTransform, int nBands,
399 Qgis::DataType type,
400 const QList<bool> &destHasNoDataValueList = QList<bool>(), const QList<double> &destNoDataValueList = QList<double>() );
401
403 void globalOutputParameters( const QgsRectangle &extent, int nCols, int &nRows, double *geoTransform, double &pixelSize );
404
405 QString partFileName( int fileIndex );
406 QString vrtFileName();
407
409 QString mOutputUrl;
410 QString mOutputProviderKey = QStringLiteral( "gdal" );
411 QString mOutputFormat = QStringLiteral( "GTiff" );
412 QStringList mCreateOptions;
414
416 bool mTiledMode = false;
417 int mMaxTileWidth = 500;
418 int mMaxTileHeight = 500;
419
420 QList< int > mPyramidsList;
421 QString mPyramidsResampling = QStringLiteral( "AVERAGE" );
424 QStringList mPyramidsConfigOptions;
425
426 QDomDocument mVRTDocument;
427 QList<QDomElement> mVRTBands;
428
429 QgsRasterBlockFeedback *mFeedback = nullptr;
430
431 const QgsRasterPipe *mPipe = nullptr;
432 const QgsRasterInterface *mInput = nullptr;
433};
434
435#endif // QGSRASTERFILEWRITER_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
RasterPyramidFormat
Raster pyramid formats.
Definition qgis.h:4466
@ GeoTiff
Geotiff .ovr (external)
RasterFileWriterResult
Raster file export results.
Definition qgis.h:1489
DataType
Raster data types.
Definition qgis.h:351
RasterBuildPyramidOption
Raster pyramid building options.
Definition qgis.h:4481
RasterExportType
Raster file export types.
Definition qgis.h:1476
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Feedback object tailored for raster block reading.
Base class for raster data providers.
The raster file writer which allows you to save a raster to a new file.
void setPyramidsList(const QList< int > &list)
Sets the list of pyramids which will be created for the output file.
enum RasterFormatOption SIP_ENUM_BASETYPE(IntFlag)
Options for sorting and filtering raster formats.
void setPyramidsResampling(const QString &str)
int maxTileHeight() const
Returns the maximum tile height (in pixels) for tiled outputs.
void setMaxTileWidth(int w)
Sets the maximum tile width (in pixels) for tiled outputs.
void setTiledMode(bool t)
Sets whether the output should be tiled.
QStringList pyramidsConfigOptions() const
Returns the list of configuration options used when creating the pyramids for the output raster file.
Qgis::RasterBuildPyramidOption buildPyramidsFlag() const
Returns the pyramid building option.
void setOutputProviderKey(const QString &key)
Sets the name of the data provider for the raster output.
void setMaxTileHeight(int h)
Sets the maximum tile height (in pixels) for tiled outputs.
QFlags< RasterFormatOption > RasterFormatOptions
Qgis::RasterPyramidFormat pyramidsFormat() const
Returns the raster pyramid format.
QString outputFormat() const
Returns the output format.
QStringList createOptions() const
Returns the list of data source creation options which will be used when creating the output raster f...
QString outputProviderKey() const
Returns the name of the data provider for the raster output.
QString pyramidsResampling() const
QList< int > pyramidsList() const
Returns the list of pyramids which will be created for the output file.
void setPyramidsFormat(Qgis::RasterPyramidFormat f)
Sets the raster pyramid format.
void setOutputFormat(const QString &format)
Sets the output format.
int maxTileWidth() const
Returns the maximum tile width (in pixels) for tiled outputs.
void setCreateOptions(const QStringList &list)
Sets a list of data source creation options to use when creating the output raster file.
bool tiledMode() const
Returns whether the output will be tiled.
void setPyramidsConfigOptions(const QStringList &list)
Sets a list of configuration options to use when creating the pyramids for the output raster file.
void setBuildPyramidsFlag(Qgis::RasterBuildPyramidOption f)
Sets the pyramid building option.
Base class for processing filters like renderers, reprojector, resampler etc.
Iterator for sequentially processing raster cells.
Contains a pipeline of raster interfaces for sequential raster processing.
A rectangle specified with double values.
#define str(x)
Definition qgis.cpp:39
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_FACTORY
Definition qgis_sip.h:76
const QgsCoordinateReferenceSystem & crs
Details of available filters and formats.
QString filterString
Filter string for file picker dialogs.