Skip to content
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

QGIS 3.39 tries to create files with SNAP_TIFF read-only driver #59112

Closed
2 tasks done
jratike80 opened this issue Oct 16, 2024 · 2 comments · Fixed by OSGeo/gdal#11037 or #59122
Closed
2 tasks done

QGIS 3.39 tries to create files with SNAP_TIFF read-only driver #59112

jratike80 opened this issue Oct 16, 2024 · 2 comments · Fixed by OSGeo/gdal#11037 or #59122
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@jratike80
Copy link

What is the bug or the crash?

I am using QGIS version 3.39.0-Master, QGIS code revision 40246d3 installed with OSGeo4W. When I try for example to clip a raster layer a GDAL command like this is created:
gdal_translate -projwin 360853.6639 6714413.7697 360961.8182 6714257.3265 -of SNAP_TIFF C:\data\dem2m.tif C:/Users/JRAHKONEN/AppData/Local/Temp/processing_giGcnu/ad37cba320a145848a03c12bed16db8d/OUTPUT.tif

Notice the output format SNAP_TIFF, that means this brand new read-only driver https://gdal.org/en/latest/drivers/raster/snap_tiff.html. The SNAP_TIFF driver cannot be used at all for writing, and it should be used only for reading some peculiar TIFF variants.

Steps to reproduce the issue

Try to clip a raster layer with GDAL - Raster extraction - Clip raster by extent. Process fails and the meaningful part of the error message is

GDAL command output:
Output driver `SNAP_TIFF' not recognised. 

Versions

QGIS version
3.39.0-Master
QGIS code revision
40246d3

Libraries
Qt version
5.15.13
Python version
3.12.6
GDAL/OGR version
3.10.0dev-b6edb5191e
PROJ version
9.4.0
EPSG Registry database version
v11.004 (2024-02-24)
GEOS version
3.12.2-CAPI-1.18.2
SQLite version
3.45.1
PDAL version
2.6.3
PostgreSQL client version
16.2
SpatiaLite version
5.1.0
QWT version
6.2.0
QScintilla2 version
2.14.1
OS version
Windows 10 Version 2009
This copy of QGIS writes debugging output.

Active Python plugins
FreehandRasterGeoreferencer
0.8.3
latlontools
3.7.1
Qgis2threejs
2.7.3
rasmover-master
version 0.2
simplewcs
0.2
wfsclient
0.9.11
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.6
processing
2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

Even Rouault claims that he could not reproduce on Linux, see comments at OSGeo/gdal#10867

@jratike80 jratike80 added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Oct 16, 2024
@agiudiceandrea agiudiceandrea added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Oct 16, 2024
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Oct 16, 2024

I can confirm the issue using QGIS 3.39.0-Master bb9a716 with GDAL/OGR 3.10.0dev-4e28921731 from OSGeo4W on Windows 10.

@jratike80 @rouault the issue is due to the fact that QgsRasterFileWriter.driverForExtension('tiff') (which is used by the processing algorithms and other tools in order to derive the correct driver for an extension) outputs "SNAP_TIFF", which, in turn, is due to the fact that the SNAP_TIFF driver has a driver index (3) lower than the driver index (4) of the GTiff driver.

QString QgsRasterFileWriter::driverForExtension( const QString &extension )
{
QString ext = extension.trimmed();
if ( ext.isEmpty() )
return QString();
if ( ext.startsWith( '.' ) )
ext.remove( 0, 1 );
GDALAllRegister();
int const drvCount = GDALGetDriverCount();
for ( int i = 0; i < drvCount; ++i )
{
GDALDriverH drv = GDALGetDriver( i );
if ( drv )
{
char **driverMetadata = GDALGetMetadata( drv, nullptr );
if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_RASTER, false ) )
{
QString drvName = GDALGetDriverShortName( drv );
const QStringList driverExtensions = QString( GDALGetMetadataItem( drv, GDAL_DMD_EXTENSIONS, nullptr ) ).split( ' ' );
const auto constDriverExtensions = driverExtensions;
for ( const QString &driver : constDriverExtensions )
{
if ( driver.compare( ext, Qt::CaseInsensitive ) == 0 )
return drvName;
}
}
}
}
return QString();
}

The issue will affect any QGIS version (even the next LTR and the Release versions) provided by OSGeo4W when GDAL 3.10 will be the default GDAL version in OSGeo4W.

@rouault
Copy link
Contributor

rouault commented Oct 16, 2024

oh well, let's not declare file extensions for the SNAP_TIFF driver: OSGeo/gdal#11037

rouault added a commit to rouault/gdal that referenced this issue Oct 16, 2024
rouault added a commit to rouault/QGIS that referenced this issue Oct 17, 2024
…/tiff extension returns the GTiff driver

Not strictly necessary since has been adressed on GDAL side per OSGeo/gdal#11037
but might be prudent for future similar situations.

Fixes qgis#59112
rouault added a commit to rouault/QGIS that referenced this issue Oct 17, 2024
…/tiff extension returns the GTiff driver

Not strictly necessary since has been adressed on GDAL side per OSGeo/gdal#11037
but might be prudent for future similar situations.

Fixes qgis#59112
rouault added a commit to rouault/QGIS that referenced this issue Oct 17, 2024
…/tiff extension returns the GTiff driver

Not strictly necessary since has been adressed on GDAL side per OSGeo/gdal#11037
but might be prudent for future similar situations.

Fixes qgis#59112
qgis-bot pushed a commit that referenced this issue Oct 18, 2024
…/tiff extension returns the GTiff driver

Not strictly necessary since has been adressed on GDAL side per OSGeo/gdal#11037
but might be prudent for future similar situations.

Fixes #59112
nyalldawson pushed a commit that referenced this issue Oct 18, 2024
…/tiff extension returns the GTiff driver

Not strictly necessary since has been adressed on GDAL side per OSGeo/gdal#11037
but might be prudent for future similar situations.

Fixes #59112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
3 participants