Bug report #14209

"Save as..." does not work for rasters

Added by Alexander Bruy almost 5 years ago. Updated over 4 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Rasters
Affected QGIS version:master Regression?:No
Operating System:all Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22211

Description

To reproduce
  1. start QGIS and load landcover.img from Alaska dataset
  2. from layer context menu choose "Save as..." and try to save raster in GeoTiff format
  3. saving failed, output layer can not be loadded in QGIS with message
    Raster layer: /tmp/test.tif is not a supported raster data source
    (src/app/qgisapp.cpp : 10501 : addRasterLayers)
    

    In console I see this
    src/core/qgsproviderregistry.cpp: 462: (function) [0ms] Library name is /home/alex/devel/cpp/qgis/build/output/lib/qgis/plugins/libgdalprovider.so
    src/providers/gdal/qgsgdalprovider.cpp: 2754: (create) [0ms] create options: 
    ERROR 1: Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.
    src/providers/gdal/qgsgdalprovider.cpp: 2764: (create) [1ms] Cannot create new dataset  /tmp/test.tif:
    Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.
    src/providers/gdal/qgsgdalproviderbase.cpp: 29: (QgsGdalProviderBase) [0ms] Entered
    src/providers/gdal/qgsgdalprovider.cpp: 227: (~QgsGdalProvider) [0ms] entering.
    src/core/qgsproviderregistry.cpp: 462: (function) [0ms] Library name is /home/alex/devel/cpp/qgis/build/output/lib/qgis/plugins/libgdalprovider.so
    ERROR 4: `/tmp/test.tif' does not exist in the file system,
    and is not recognised as a supported dataset name.
    

    It works fine in 2.12, but fails in master.

saveas.png - Screenshot of "Save as" dialog with correct values (69.3 KB) Alexander Bruy, 2016-02-03 05:13 AM

Associated revisions

Revision 8fc40564
Added by Nyall Dawson over 4 years ago

Default to layer CRS in raster save as dialog (fix #14209)

Revision 25ac01aa
Added by Nyall Dawson over 4 years ago

Default to layer CRS in raster save as dialog (fix #14209)

(cherry-picked from 8fc405648be18870133e318cbfc7cb0918efe4b1)

History

#1 Updated by Luigi Pirelli almost 5 years ago

confirmed with the following revision beaa45e

src/providers/gdal/qgsgdalprovider.cpp: 2480: (bandStatistics) [0ms] STDDEV 3.03972
src/core/qgsproviderregistry.cpp: 462: (function) [0ms] Library name is /home/ginetto/PROGRAMMING/QGIS-Boundless/build/output/lib/qgis/plugins/libgdalprovider.so
src/providers/gdal/qgsgdalprovider.cpp: 2754: (create) [0ms] create options: 
ERROR 1: Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.
src/providers/gdal/qgsgdalprovider.cpp: 2764: (create) [0ms] Cannot create new dataset  /home/ginetto/Downloads/pippo.tif:
Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.
src/providers/gdal/qgsgdalproviderbase.cpp: 29: (QgsGdalProviderBase) [0ms] Entered
src/providers/gdal/qgsgdalprovider.cpp: 227: (~QgsGdalProvider) [1ms] entering.
src/core/qgsproviderregistry.cpp: 462: (function) [0ms] Library name is /home/ginetto/PROGRAMMING/QGIS-Boundless/build/output/lib/qgis/plugins/libgdalprovider.so
ERROR 4: `/home/ginetto/Downloads/pippo.tif' does not exist in the file system,
and is not recognised as a supported dataset name.

#2 Updated by Radim Blazek almost 5 years ago

  • Assignee deleted (Radim Blazek)

I found the raster save as dialog pretty broken. CRS and size/resolution are not set correctly by default, which results for example in "Attempt to create 0x0 dataset".

#3 Updated by Nyall Dawson almost 5 years ago

Radim - looks ok to me. What circumstances do you see the incorrect values?

#4 Updated by Alexander Bruy almost 5 years ago

Also looks fine here. Extent, CRS and size set correctly. Screenshoot attached.

#5 Updated by Radim Blazek almost 5 years ago

I have Settings > Options > CRS > Don't enable 'on the fly' reprojection

If I add landcover.img (EPSG 2964, 3663x1964, resolution 3280) and open save as, it is set to:

CRS: EPSG 4326
Extent: -179.96750606303607, 49.18115186042209, 179.99678395391788, 71.42336747479702
Resolution 3280, 3280
Size: 0, 0

It should be set to the original raster values. In any case, extent is in EPSG 4326 while resolution in EPSG 2964, that is also why the size is 0x0.

Alexander Bruy wrote:

Also looks fine here. Extent, CRS and size set correctly. Screenshoot attached.

Correctly? Is not the size 0x0? Does not that fail with "Attempt to create 0x0 dataset"?

#6 Updated by Nyall Dawson almost 5 years ago

Does this happen every time for you? I can't reliably reproduce it. For me (with OTF off) it defaults to the project CRS, and the derived values are correctly set.

I'm not sure if the dialog should default to the layer CRS or project CRS, but that's a different discussion....

#7 Updated by Radim Blazek almost 5 years ago

Playing with landcover.img, I found more serious #14229.

Nyall Dawson wrote:

Does this happen every time for you? I can't reliably reproduce it. For me (with OTF off) it defaults to the project CRS, and the derived values are correctly set.

Excent/resolution/size are initially wrong only if project is in geographic CRS. If you switch then manually in save as dialog to another (or even to the same) CRS, the values are corrected.

I'm not sure if the dialog should default to the layer CRS or project CRS, but that's a different discussion....

I believe that default should be layer's CRS, extent and size, otherwise data are lost and that should only happen intentionally (manually select). Apart loosing data, it can also result in huge output raster, take for example our example, if output CRS for landcover.img is set to epsg:4326, it calculates resolution 0.000951617,0.0126326 and size 378266,1761! Hardly useful.

#8 Updated by Nyall Dawson over 4 years ago

  • Status changed from Open to Closed

#9 Updated by Nyall Dawson over 4 years ago

Should be fixed with #14392, and the above commit switches the default CRS to match the layer CRS rather than the project CRS.

Also available in: Atom PDF