[QGIS-Developer] 2 questions on saving rasters in 3.4

Andreas Neumann a.neumann at carto.net
Thu Jan 24 05:05:08 PST 2019

Hi Nyall, 

On 2019-01-24 11:09, Nyall Dawson wrote:

> On Thu, 24 Jan 2019 at 17:59, Andreas Neumann <a.neumann at carto.net> wrote: 
>> Hi,
>> I have two questions about saving rasters in QGIS 3.4:
>> 1.
>> If I use "Right-klick layer" --> "Export" --> "Save AS" then I can't choose the ESRI ASCII Grid format described in "Settings" --> "Options" --> "GDAL" as "AAIGrid".
>> Any idea why this format is not available for exporting rasters?
> The raster file writer only currently supports formats for which GDAL
> has "creation" support, not "copy" . See
> https://www.gdal.org/formats_list.html - AAIGrid supports copies only.
> This should be fixable with moderate effort -- we could create a
> temporary dataset in a supported format (possibly even in memory for
> smaller rasters), and then use GDAL's createcopy to write the result.
> This would open up support for all raster drivers with copy but not
> create support, including AAigrid, and a whole lot of other useful
> formats too.

Thank you for the explanation. This is useful to know. It would be a
nice thing to have "Save AS" also for formats that have no GDAL creation

>> 2.
>> As an alternative I can use the "Raster" --> "Extraction" --> "Clip raster by extent". This works fine, but I can't set the number of decimal places after the comma.
>> E.g. if I export a terrain model I would like to use 2-3 places after the decimal, not the full 8 digits, which is a false accuracy.
> I don't fully understand the issue here -- although the dialog is
> showing that many decimal places, it doesn't affect the output file if
> the extraneous digits are set to 0.
> Nyall

Ok - I try to explain it better: 

My data is originally coming from an ESRI ascii grid. It had been many
hundred tiles of ascii grids which I merged into a single big GEOTIFF
file. The original data had up to 3 digits after the decimal point for
the terrain height (mm accuracy) per cell. After import to the Geotiff
the data has now many more (useless) digits after the comma, because the
number of the digits in the geotiff is now defined by the float32 data
type I chose. When I export that data back to ESRI ascii grid I get 15!
digits after the decimal point. I would like to round it back to 2
digits after the decimal point (cm accuracy). 

In addition, the header in the resulting asciigrid has now many useless
digits. It looks like this: 

ncols 233
nrows 189
xllcorner 2681471.893245012965
yllcorner 1224297.020738559077
dx 0.999927877238
dy 1.000035130719
NODATA_value 0 

Note that the resolution of the data is 1m. But in the export it comes
out as dx 0.999927877238 - dy 1.000035130719 

I wonder if I could force the resolution back to 1.0 (the original

So it is an issue of rounding/accuracy. 

Thanks again, 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190124/546e0544/attachment.html>

More information about the QGIS-Developer mailing list