New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for postgresraster based rasters in Raster Calculator #43440
Conversation
@@ -735,7 +735,7 @@ QVector<QgsRasterCalculatorEntry> QgsRasterCalculatorEntry::rasterEntries() | |||
for ( ; layerIt != layers.constEnd(); ++layerIt ) | |||
{ | |||
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layerIt.value() ); | |||
if ( rlayer && rlayer->dataProvider() && rlayer->providerType() == QLatin1String( "gdal" ) ) | |||
if ( rlayer && rlayer->dataProvider() && ( rlayer->providerType() == QLatin1String( "gdal" ) || rlayer->providerType() == QLatin1String( "postgresraster" ) ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason to test the providerType() at all ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so @rouault, at least for now.
If not, wms
layers, for example, would also be listed in the raster calculator. Are we able to handle wms
layers properly in the raster calculator?
I've done a quick test. I was not able to use the raster calculator with a WMS layer. Raster Calculator is not able to estimate the row and columns numbers from the source (using the Selected Layer Extent button), for example, as we do for a gdal
or postgresqraster
raster. Writing down the size of the output raster was not enough. I've got many src/core/raster/qgsrasterblock.h:818 : (valueAndNoData) [0ms] Data block not allocated
errors while reading the data blocks.
In my opinion, we would need to review all descendant classes of QgsRasterLayer
before allowing them to be listed in the raster calculator.
What do you think? Should we list all QgsRasterLayer
descendant classes here and fix the failing issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps testing for (capabilities() & QgsRasterDataProvider::Size) != 0 which is true for the GDAL provider and PostgisRaster one, but not the WMS one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've improved the condition. It doesn't use provider literal names anymore. Thanks @rouault for the tip.
I've also removed the condition from the dialog itself. The list is provided by rasterEntries()
where the condition makes sense. It was unnecessary duplicated on the dialog side.
Description
This PR makes both gdal and postgresraster based rasters available in the Raster Calculator.
Fix #43439
I've tested two or three raster operations and it worked fine with theses rasters (as expected).
The Raster Calculator, opened from processing tool also include these rasters now.