23#include "moc_qgsrasterlayersaveasdialog.cpp"
39#include <QRegularExpression>
44 QWidget *parent, Qt::WindowFlags f )
45 : QDialog( parent, f )
46 , mRasterLayer( rasterLayer )
47 , mDataProvider( sourceProvider )
48 , mCurrentExtent( currentExtent )
49 , mLayerCrs( layerCrs )
50 , mCurrentCrs( currentCrs )
51 , mResolutionState( OriginalResolution )
55 connect( mRawModeRadioButton, &QRadioButton::toggled,
this, &QgsRasterLayerSaveAsDialog::mRawModeRadioButton_toggled );
56 connect( mFormatComboBox, &QComboBox::currentTextChanged,
this, &QgsRasterLayerSaveAsDialog::mFormatComboBox_currentIndexChanged );
57 connect( mResolutionRadioButton, &QRadioButton::toggled,
this, &QgsRasterLayerSaveAsDialog::mResolutionRadioButton_toggled );
58 connect( mOriginalResolutionPushButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mOriginalResolutionPushButton_clicked );
59 connect( mXResolutionLineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerSaveAsDialog::mXResolutionLineEdit_textEdited );
60 connect( mYResolutionLineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerSaveAsDialog::mYResolutionLineEdit_textEdited );
61 connect( mOriginalSizePushButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mOriginalSizePushButton_clicked );
62 connect( mColumnsLineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerSaveAsDialog::mColumnsLineEdit_textEdited );
63 connect( mRowsLineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerSaveAsDialog::mRowsLineEdit_textEdited );
64 connect( mAddNoDataManuallyToolButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mAddNoDataManuallyToolButton_clicked );
65 connect( mLoadTransparentNoDataToolButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mLoadTransparentNoDataToolButton_clicked );
66 connect( mRemoveSelectedNoDataToolButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mRemoveSelectedNoDataToolButton_clicked );
67 connect( mRemoveAllNoDataToolButton, &QPushButton::clicked,
this, &QgsRasterLayerSaveAsDialog::mRemoveAllNoDataToolButton_clicked );
68 connect( mTileModeCheckBox, &QCheckBox::toggled,
this, &QgsRasterLayerSaveAsDialog::mTileModeCheckBox_toggled );
69 connect( mPyramidsGroupBox, &QgsCollapsibleGroupBox::toggled,
this, &QgsRasterLayerSaveAsDialog::mPyramidsGroupBox_toggled );
75 mNoDataTableWidget->setColumnCount( 2 );
76 mNoDataTableWidget->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"From" ) ) );
77 mNoDataTableWidget->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"To" ) ) );
79 mRawModeRadioButton_toggled(
true );
83 toggleResolutionSize();
85 insertAvailableOutputFormats();
92 setOriginalResolution();
93 int xSize = mDataProvider->
xSize();
94 int ySize = mDataProvider->
ySize();
95 mMaximumSizeXLineEdit->setText( QString::number( xSize ) );
96 mMaximumSizeYLineEdit->setText( QString::number( ySize ) );
100 mTileModeCheckBox->setChecked(
true );
101 mMaximumSizeXLineEdit->setText( QString::number( 2000 ) );
102 mMaximumSizeYLineEdit->setText( QString::number( 2000 ) );
106 mCreateOptionsWidget->setProvider( mDataProvider->
name() );
107 if ( mDataProvider->
name() == QLatin1String(
"gdal" ) )
109 mCreateOptionsWidget->setFormat( mFormatComboBox->currentData().toString() );
111 mCreateOptionsWidget->setRasterLayer( mRasterLayer );
112 mCreateOptionsWidget->update();
121 mPyramidsOptionsWidget->createOptionsWidget()->setRasterLayer( mRasterLayer );
126 mPyramidsUseExistingCheckBox->setEnabled(
false );
127 mPyramidsUseExistingCheckBox->setVisible(
false );
129 populatePyramidsLevels();
131 this, &QgsRasterLayerSaveAsDialog::populatePyramidsLevels );
135 mPyramidsGroupBox->setEnabled(
false );
136 mPyramidsGroupBox->setCollapsed(
true );
141 mCreateOptionsGroupBox->setSaveCheckedState(
true );
151 mCrsSelector->setSourceEnsemble( ensemble.
name() );
157 mCrsSelector->setShowAccuracyWarnings(
true );
159 mCrsSelector->setLayerCrs( mLayerCrs );
161 mCrsSelector->setCrs( mLayerCrs );
164 this, &QgsRasterLayerSaveAsDialog::crsChanged );
166 QPushButton *okButton = mButtonBox->button( QDialogButtonBox::Ok );
169 okButton->setEnabled(
false );
173 mHelpButtonBox->setVisible(
false );
174 mButtonBox->addButton( QDialogButtonBox::Help );
175 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerSaveAsDialog::showHelp );
177 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerSaveAsDialog::showHelp );
180 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QgsRasterLayerSaveAsDialog::reject );
182 mExtentGroupBox->setOutputCrs(
outputCrs() );
183 mExtentGroupBox->setOriginalExtent( mDataProvider->
extent(), mLayerCrs );
184 mExtentGroupBox->setCurrentExtent( mCurrentExtent, mCurrentCrs );
185 mExtentGroupBox->setOutputExtentFromOriginal();
188 recalcResolutionSize();
192 if ( mTileModeCheckBox->isChecked() )
194 mTilesGroupBox->show();
196 mFilename->setDialogTitle( tr(
"Select Output Directory" ) );
200 mTilesGroupBox->hide();
202 mFilename->setDialogTitle( tr(
"Save Layer As" ) );
205 mFilename->setDefaultRoot( settings.
value( QStringLiteral(
"UI/lastRasterFileDir" ), QDir::homePath() ).toString() );
209 QFileInfo tmplFileInfo( filePath );
210 settings.
setValue( QStringLiteral(
"UI/lastRasterFileDir" ), tmplFileInfo.absolutePath() );
212 if ( !filePath.isEmpty() && mLayerName->isEnabled() )
214 QFileInfo fileInfo( filePath );
215 mLayerName->setText( fileInfo.baseName() );
218 if ( mTileModeCheckBox->isChecked() )
220 QString fileName = filePath;
225 if ( fileName.isEmpty() )
229 QDir dir( fileName );
230 QString baseName = QFileInfo( fileName ).baseName();
232 filters << QStringLiteral(
"%1.*" ).arg( baseName );
233 QStringList files = dir.entryList( filters );
234 if ( files.isEmpty() )
237 if ( QMessageBox::warning(
this, tr(
"Save Raster Layer" ),
238 tr(
"The directory %1 contains files which will be overwritten: %2" ).arg( dir.absolutePath(), files.join( QLatin1String(
", " ) ) ),
239 QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok )
242 fileName = QFileDialog::getExistingDirectory(
this, tr(
"Select output directory" ), tmplFileInfo.absolutePath() );
246 QPushButton *okButton = mButtonBox->button( QDialogButtonBox::Ok );
251 okButton->setEnabled( tmplFileInfo.absoluteDir().exists() );
255void QgsRasterLayerSaveAsDialog::insertAvailableOutputFormats()
259 int nDrivers = GDALGetDriverCount();
260 QMap< int, QPair< QString, QString > > topPriorityDrivers;
261 QMap< QString, QString > lowPriorityDrivers;
263 for (
int i = 0; i < nDrivers; ++i )
265 GDALDriverH driver = GDALGetDriver( i );
270 QString driverShortName = GDALGetDriverShortName( driver );
271 QString driverLongName = GDALGetDriverLongName( driver );
272 if ( driverShortName == QLatin1String(
"MEM" ) )
279 else if ( driverShortName == QLatin1String(
"VRT" ) )
284 else if ( driverShortName == QLatin1String(
"GTiff" ) )
287 topPriorityDrivers.insert( 1, qMakePair( driverLongName, driverShortName ) );
289 else if ( driverShortName == QLatin1String(
"GPKG" ) )
292 topPriorityDrivers.insert( 2, qMakePair( driverLongName, driverShortName ) );
296 lowPriorityDrivers.insert( driverLongName, driverShortName );
303 for (
auto priorityDriversIt = topPriorityDrivers.constBegin(); priorityDriversIt != topPriorityDrivers.constEnd(); ++priorityDriversIt )
305 mFormatComboBox->addItem( priorityDriversIt.value().first, priorityDriversIt.value().second );
308 for (
auto lowPriorityDriversIt = lowPriorityDrivers.constBegin(); lowPriorityDriversIt != lowPriorityDrivers.constEnd(); ++lowPriorityDriversIt )
310 mFormatComboBox->addItem( lowPriorityDriversIt.key(), lowPriorityDriversIt.value() );
315void QgsRasterLayerSaveAsDialog::setValidators()
319 mColumnsLineEdit->setValidator(
new QIntValidator(
this ) );
320 mRowsLineEdit->setValidator(
new QIntValidator(
this ) );
321 mMaximumSizeXLineEdit->setValidator(
new QIntValidator(
this ) );
322 mMaximumSizeYLineEdit->setValidator(
new QIntValidator(
this ) );
325void QgsRasterLayerSaveAsDialog::mFormatComboBox_currentIndexChanged(
const QString & )
328 if ( mDataProvider && mDataProvider->
name() == QLatin1String(
"gdal" ) )
331 mCreateOptionsWidget->update();
336 if ( extensions.empty() )
337 filter = tr(
"All files (*.*)" );
340 filter = QStringLiteral(
"%1 (*.%2);;%3" ).arg( mFormatComboBox->currentText(),
341 extensions.join( QLatin1String(
" *." ) ),
342 tr(
"All files (*.*)" ) );
344 mFilename->setFilter( filter );
347 mTileModeCheckBox->setEnabled(
outputFormat() != QLatin1String(
"GPKG" ) );
348 mFilename->setConfirmOverwrite(
outputFormat() != QLatin1String(
"GPKG" ) );
349 mLayerName->setEnabled(
outputFormat() == QLatin1String(
"GPKG" ) );
350 if ( mLayerName->isEnabled() )
352 QString layerName = QFileInfo( mFilename->filePath() ).baseName();
353 mLayerName->setText( layerName );
354 mTileModeCheckBox->setChecked(
false );
358 mLayerName->setText( QString() );
364 return mColumnsLineEdit->text().toInt();
369 return mRowsLineEdit->text().toInt();
384 return mMaximumSizeXLineEdit->text().toInt();
389 return mMaximumSizeYLineEdit->text().toInt();
394 return mTileModeCheckBox->isChecked();
399 return mAddToCanvas->isChecked();
404 mAddToCanvas->setChecked( checked );
409 QString fileName = mFilename->filePath();
415 if ( !extensions.empty() )
417 defaultExt = extensions.at( 0 );
421 QFileInfo fi( fileName );
422 if ( !fileName.isEmpty() && fi.suffix().isEmpty() && !defaultExt.isEmpty() )
424 fileName +=
'.' + defaultExt;
433 if ( mLayerName->text().isEmpty() &&
outputFormat() == QLatin1String(
"GPKG" ) && !mTileModeCheckBox->isChecked() )
436 return QFileInfo( mFilename->filePath() ).baseName();
440 return mLayerName->text();
446 return mFormatComboBox->currentData().toString();
451 QStringList options = mCreateOptionsGroupBox->isChecked() ? mCreateOptionsWidget->options() : QStringList();
455 int indx = options.indexOf( QRegularExpression(
"^RASTER_TABLE=.*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption ) );
458 options.replace( indx, QStringLiteral(
"RASTER_TABLE=%1" ).arg(
outputLayerName() ) );
462 options.append( QStringLiteral(
"RASTER_TABLE=%1" ).arg(
outputLayerName() ) );
466 if ( !outputLayerExists() )
468 indx = options.indexOf( QRegularExpression(
"^APPEND_SUBDATASET=.*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption ) );
471 options.replace( indx, QStringLiteral(
"APPEND_SUBDATASET=YES" ) );
475 options.append( QStringLiteral(
"APPEND_SUBDATASET=YES" ) );
484 return mExtentGroupBox->outputExtent();
489 mFormatLabel->hide();
490 mFormatComboBox->hide();
495 mSaveAsLabel->hide();
497 QPushButton *okButton = mButtonBox->button( QDialogButtonBox::Ok );
500 okButton->setEnabled(
true );
504void QgsRasterLayerSaveAsDialog::toggleResolutionSize()
508 bool on = mResolutionRadioButton->isChecked();
509 mXResolutionLineEdit->setEnabled( on );
510 mYResolutionLineEdit->setEnabled( on );
511 mOriginalResolutionPushButton->setEnabled( on && hasResolution );
512 mColumnsLineEdit->setEnabled( !on );
513 mRowsLineEdit->setEnabled( !on );
514 mOriginalSizePushButton->setEnabled( !on && hasResolution );
517void QgsRasterLayerSaveAsDialog::setOriginalResolution()
529 xRes = yRes = mDataProvider->
extent().
width() / 100;
531 setResolution( xRes, yRes, mLayerCrs );
549 QgsRectangle srcExtent( srsCenter.
x() - xRes / 2, srsCenter.
y() - yRes / 2, srsCenter.
x() + xRes / 2, srsCenter.
y() + yRes / 2 );
552 xRes = extent.
width();
555 mXResolutionLineEdit->setText( QLocale().toString( xRes ) );
556 mYResolutionLineEdit->setText( QLocale().toString( yRes ) );
559void QgsRasterLayerSaveAsDialog::recalcSize()
564 mColumnsLineEdit->setText( QString::number( xSize ) );
565 mRowsLineEdit->setText( QString::number( ySize ) );
566 updateResolutionStateMsg();
569void QgsRasterLayerSaveAsDialog::setOriginalSize()
571 mColumnsLineEdit->setText( QString::number( mDataProvider->
xSize() ) );
572 mRowsLineEdit->setText( QString::number( mDataProvider->
ySize() ) );
576void QgsRasterLayerSaveAsDialog::recalcResolution()
581 mXResolutionLineEdit->setText( QLocale().toString( xRes ) );
582 mYResolutionLineEdit->setText( QLocale().toString( yRes ) );
583 updateResolutionStateMsg();
586void QgsRasterLayerSaveAsDialog::recalcResolutionSize()
588 if ( mResolutionRadioButton->isChecked() )
599void QgsRasterLayerSaveAsDialog::updateResolutionStateMsg()
602 switch ( mResolutionState )
608 msg = tr(
"user defined" );
613 msg = tr(
"Resolution (current: %1)" ).arg( msg );
614 mResolutionGroupBox->setTitle( msg );
617void QgsRasterLayerSaveAsDialog::extentChanged()
620 if ( mSizeRadioButton->isChecked() )
624 recalcResolutionSize();
627void QgsRasterLayerSaveAsDialog::crsChanged()
631 mExtentGroupBox->setOutputCrs(
outputCrs() );
634 if ( mResolutionRadioButton->isChecked() )
638 setOriginalResolution();
657 return mCrsSelector->crs();
666void QgsRasterLayerSaveAsDialog::mRawModeRadioButton_toggled(
bool checked )
668 mNoDataGroupBox->setEnabled( checked && mDataProvider->
bandCount() == 1 );
669 mNoDataGroupBox->setCollapsed( !mNoDataGroupBox->isEnabled() );
672void QgsRasterLayerSaveAsDialog::mAddNoDataManuallyToolButton_clicked()
674 addNoDataRow( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN() );
677void QgsRasterLayerSaveAsDialog::mLoadTransparentNoDataToolButton_clicked()
679 if ( !mRasterLayer->
renderer() )
return;
681 if ( !rasterTransparency )
return;
688 addNoDataRow( transparencyPixel.min, transparencyPixel.max );
689 if ( transparencyPixel.min != transparencyPixel.max )
691 setNoDataToEdited( mNoDataTableWidget->rowCount() - 1 );
697void QgsRasterLayerSaveAsDialog::mRemoveSelectedNoDataToolButton_clicked()
699 mNoDataTableWidget->removeRow( mNoDataTableWidget->currentRow() );
702void QgsRasterLayerSaveAsDialog::mRemoveAllNoDataToolButton_clicked()
704 while ( mNoDataTableWidget->rowCount() > 0 )
706 mNoDataTableWidget->removeRow( 0 );
710void QgsRasterLayerSaveAsDialog::addNoDataRow(
double min,
double max )
712 mNoDataTableWidget->insertRow( mNoDataTableWidget->rowCount() );
713 for (
int i = 0; i < 2; i++ )
715 double value = i == 0 ? min : max;
716 QLineEdit *lineEdit =
new QLineEdit();
717 lineEdit->setFrame(
false );
718 lineEdit->setContentsMargins( 1, 1, 1, 1 );
725 if ( !std::isnan( value ) )
731 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
732 if ( !std::isnan( value ) )
734 valueString = QLocale().toString(
static_cast<int>( value ) );
738 lineEdit->setText( valueString );
739 mNoDataTableWidget->setCellWidget( mNoDataTableWidget->rowCount() - 1, i, lineEdit );
741 adjustNoDataCellWidth( mNoDataTableWidget->rowCount() - 1, i );
743 connect( lineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerSaveAsDialog::noDataCellTextEdited );
745 mNoDataTableWidget->resizeColumnsToContents();
746 mNoDataTableWidget->resizeRowsToContents();
749void QgsRasterLayerSaveAsDialog::noDataCellTextEdited(
const QString &text )
753 QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
754 if ( !lineEdit )
return;
757 for (
int r = 0; r < mNoDataTableWidget->rowCount(); r++ )
759 for (
int c = 0;
c < mNoDataTableWidget->columnCount();
c++ )
761 if ( mNoDataTableWidget->cellWidget( r,
c ) == sender() )
768 if ( row != -1 )
break;
770 QgsDebugMsgLevel( QStringLiteral(
"row = %1 column =%2" ).arg( row ).arg( column ), 2 );
774 QLineEdit *toLineEdit =
dynamic_cast<QLineEdit *
>( mNoDataTableWidget->cellWidget( row, 1 ) );
775 if ( !toLineEdit )
return;
776 bool toChanged = mNoDataToEdited.value( row );
780 toLineEdit->setText( lineEdit->text() );
783 else if ( column == 1 )
785 setNoDataToEdited( row );
789void QgsRasterLayerSaveAsDialog::mTileModeCheckBox_toggled(
bool toggled )
808 mTilesGroupBox->show();
810 mFilename->setDialogTitle( tr(
"Select Output Directory" ) );
814 mTilesGroupBox->hide();
816 mFilename->setDialogTitle( tr(
"Save Layer As" ) );
820void QgsRasterLayerSaveAsDialog::mPyramidsGroupBox_toggled(
bool toggled )
823 populatePyramidsLevels();
826void QgsRasterLayerSaveAsDialog::populatePyramidsLevels()
830 if ( mPyramidsGroupBox->isChecked() )
832 QList<QgsRasterPyramid> myPyramidList;
835 if ( mPyramidsUseExistingCheckBox->isChecked() )
841 if ( ! mPyramidsOptionsWidget->overviewList().isEmpty() )
842 myPyramidList = mDataProvider->
buildPyramidList( mPyramidsOptionsWidget->overviewList() );
846 if ( ! mPyramidsUseExistingCheckBox->isChecked() || pyramid.getExists() )
848 text += QString::number( pyramid.getXDim() ) + QStringLiteral(
"x" ) +
849 QString::number( pyramid.getYDim() ) +
' ';
854 mPyramidResolutionsLineEdit->setText( text.trimmed() );
857void QgsRasterLayerSaveAsDialog::setNoDataToEdited(
int row )
859 if ( row >= mNoDataToEdited.size() )
861 mNoDataToEdited.resize( row + 1 );
863 mNoDataToEdited[row] =
true;
866double QgsRasterLayerSaveAsDialog::noDataCellValue(
int row,
int column )
const
868 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mNoDataTableWidget->cellWidget( row, column ) );
869 if ( !lineEdit || lineEdit->text().isEmpty() )
871 return std::numeric_limits<double>::quiet_NaN();
876void QgsRasterLayerSaveAsDialog::adjustNoDataCellWidth(
int row,
int column )
878 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mNoDataTableWidget->cellWidget( row, column ) );
879 if ( !lineEdit )
return;
881 int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
882 width = std::max( width, mNoDataTableWidget->columnWidth( column ) );
884 lineEdit->setFixedWidth( width );
890 if ( ! mNoDataGroupBox->isChecked() )
893 int rows = mNoDataTableWidget->rowCount();
894 noDataList.reserve( rows );
895 for (
int r = 0; r < rows; r++ )
898 noDataList.append(
noData );
906 return mPyramidsGroupBox->isChecked() ? mPyramidsOptionsWidget->overviewList() : QList<int>();
911 if ( ! mPyramidsGroupBox->isChecked() )
913 else if ( mPyramidsUseExistingCheckBox->isChecked() )
919bool QgsRasterLayerSaveAsDialog::validate()
const
921 if ( mCreateOptionsGroupBox->isChecked() )
923 QString message = mCreateOptionsWidget->validateOptions(
true,
false );
924 if ( !message.isNull() )
927 if ( mPyramidsGroupBox->isChecked() )
929 QString message = mPyramidsOptionsWidget->createOptionsWidget()->validateOptions(
true,
false );
930 if ( !message.isNull() )
936bool QgsRasterLayerSaveAsDialog::outputLayerExists()
const
950 QgsRasterLayer rasterLayer( rasterUri, QString( ), QStringLiteral(
"gdal" ) );
951 if ( !vectorUri.isEmpty() )
953 QgsVectorLayer vectorLayer( vectorUri, QString( ), QStringLiteral(
"ogr" ) );
954 return rasterLayer.isValid() || vectorLayer.isValid();
958 return rasterLayer.isValid();
971 const int nbTilesWidth = std::ceil(
nColumns() / 256 );
972 const int nbTilesHeight = std::ceil(
nRows() / 256 );
973 int64_t totalTiles =
static_cast<int64_t
>( nbTilesWidth ) * nbTilesHeight;
977 QMessageBox::warning(
this, tr(
"Save Raster Layer" ),
978 tr(
"The number of OpenStreetMap tiles needed to produce the raster layer is too large and will lead to bulk downloading behavior which is prohibited by the %1OpenStreetMap Foundation tile usage policy%2." ).arg( QStringLiteral(
"<a href=\"https://operations.osmfoundation.org/policies/tiles/\">" ), QStringLiteral(
"</a>" ) ),
984 if (
outputFormat() == QLatin1String(
"GPKG" ) && outputLayerExists() &&
985 QMessageBox::warning(
this, tr(
"Save Raster Layer" ),
986 tr(
"The layer %1 already exists in the target file, and overwriting layers in GeoPackage is not supported. "
988 QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
996void QgsRasterLayerSaveAsDialog::showHelp()
998 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/create_layers.html#creating-new-layers-from-an-existing-layer" ) );
@ BuildPyramids
Supports building of pyramids (overviews) (since QGIS 3.38 – this is a replacement for RasterInterfac...
@ BuildPyramids
Supports building of pyramids (overviews) (Deprecated since QGIS 3.38 – use RasterProviderCapability:...
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
@ Float32
Thirty two bit floating point (float)
@ Float64
Sixty four bit floating point (double)
RasterBuildPyramidOption
Raster pyramid building options.
@ CopyExisting
Copy existing.
@ Reverse
Reverse/inverse transform (from destination to source)
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
This class represents a coordinate reference system (CRS).
QgsDatumEnsemble datumEnsemble() const
Attempts to retrieve datum ensemble details from the CRS.
virtual QString name() const =0
Returns a provider name.
Contains information about a datum ensemble.
bool isValid() const
Returns true if the datum ensemble is a valid object, or false if it is a null/invalid object.
QString name() const
Display name of datum ensemble.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
void extentChanged(const QgsRectangle &r)
Emitted when the widget's extent is changed.
static bool supportsRasterCreate(GDALDriverH driver)
Reads whether a driver supports GDALCreate() for raster purposes.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static bool isOpenStreetMapLayer(QgsMapLayer *layer)
Returns true if the layer is served by OpenStreetMap server.
Custom exception class which is raised when an operation is not supported.
A class to represent a 2D point.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QString printValue(double value, bool localized=false)
Print double value with all necessary significant digits.
Base class for raster data providers.
Qgis::DataType sourceDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
static QStringList extensionsForFormat(const QString &format)
Returns a list of known file extensions for the given GDAL driver format.
virtual Qgis::RasterInterfaceCapabilities capabilities() const
Returns the capabilities supported by the interface.
virtual int xSize() const
Gets raster size.
virtual int bandCount() const =0
Gets number of bands.
virtual int ySize() const
double xResolution() const
double yResolution() const
QgsRasterRangeList noData() const
int maximumTileSizeX() const
QString outputLayerName() const
Name of the output layer within GeoPackage file.
QList< int > pyramidsList() const
Qgis::RasterBuildPyramidOption buildPyramidsFlag() const
Returns the pyramid building option.
QString outputFormat() const
QgsRectangle outputRectangle() const
QgsRasterLayerSaveAsDialog(QgsRasterLayer *rasterLayer, QgsRasterDataProvider *sourceProvider, const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem &layerCrs, const QgsCoordinateReferenceSystem ¤tCrs, QWidget *parent SIP_TRANSFERTHIS=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructor for QgsRasterLayerSaveAsDialog.
bool addToCanvas() const
Returns true if the "add to canvas" checkbox is checked.
QStringList createOptions() const
int maximumTileSizeY() const
void setAddToCanvas(bool checked)
Sets whether the "add to canvas" checkbox should be checked.
QgsCoordinateReferenceSystem outputCrs()
QString outputFileName() const
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
This struct is used to store pyramid info for the raster layer.
Raster values range container.
const QgsRasterTransparency * rasterTransparency() const
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
QVector< QgsRasterTransparency::TransparentSingleValuePixel > transparentSingleValuePixelList() const
Returns the transparent single value pixel list.
A rectangle specified with double values.
double width() const
Returns the width of the rectangle.
QgsPointXY center() const
Returns the center point of the rectangle.
double height() const
Returns the height of the rectangle.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Represents a vector layer which manages a vector based data sets.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define QgsDebugMsgLevel(str, level)
#define MAXIMUM_OPENSTREETMAP_TILES_FETCH
QList< QgsRasterRange > QgsRasterRangeList
Defines the transparency for a range of single-band pixel values.