6

I have a .vrt file that references (i.e. was created based on) five .tif files (whose sizes are 1.3 MB, 2.7 MB, 330 MB, 4 MB and 2.7 MB). These files represent a Digital Elevation Model (DEM), where the third file is the most general file and the other 4 are refinements of the channel of the river draining the area.

I want to get a .tif file from the .vrt file, but when i do this i get a 4.5 GB file, which for me is excessively large compared to the original .tif files.

  • I double checked the pixel size and all files (including the .vrt and the output .tif) have the same resolution.
  • All of them have the same data type (Float 32).
  • All .tif files have the same coordinate system (EPSG 29193), but the .vrt file has a User defined projected CRS. The .vrt file was created using Ras Mapper from (HEC-RAS).

Does anyone know why exporting the .vrt file increases the file size so much?

and

What could i do to reduce/compress the output .tif file?

I exported the .vrt to .tif using QGIS 3.6 and would prefer to stick to this software to find a solution.

Am now trying to export the output .tif from the original .tifs, however, i still want to understand what may be the issue transforming .vrt to .tif.

0

3 Answers 3

6

The vrt is a small xml file pointing to existing rasters. When you convert it to a raster, you will write all the information from the input raster in a new file.

The extent of the output file will be the extent of the vrt file, which is by default the extent rectangle that contains all the rectangles of input files. If there are gaps between the input files, there will be more pixels in the resulting raster file, hence it will be larger than the sum of the inputs (even if the pixels are NoData pixels).

By default, converting to raster will not apply any compression to the dataset. For the best possible compression, here are a few tricks :

1) don't use Float32 if not necessary, because the compression rate of Float32 is lower than Byte and Integer, and raw float 32 is larger than Byte and int32. If you multiply your elevation values by 10, you will be able to store your elevation values in integer16 with 10 cm precision, which is usually more than enough.

2) With most geographic data, you can take advantage of the spatial autocorrelation when compressing the data. Use additionnal option PREDICTOR=2 with Int16 and PREDICTOR=3 with Float32 to increase the compression rate.

In practice, with QGIS 3, once you go to the raster > conversion > translate form, you can add creation parameters with the green cross, for instance

enter image description here

Remark: reading a compressed file is slower than reading an uncompressed file, so it is not always a good thing to compress your data.

4

Your input tifs may be compressed and you are outputting an uncompressed tif. To output a compressed tif, use the Processing Toolbox -> GDAL -> Translate (Convert Format) and specify High compression in the Advanced parameters -> Additional Creation options -> Profile

enter image description here

enter image description here

0

From: https://research.csc.fi/virtual_rasters , "Virtual datasets are useful for managing large datasets that are split into multiple files. ... Virtual rasters are just xml files that tell GDAL where actual data can be found but from user's point of view virtual rasters can be treated much like any other raster format" . This is the reason why a virtual Raster file uses little space. When you merge, instead of building a virtual Raster, you phisically unite the input rasters and that is why the amount of space used in a geotiff is the sum of the input file sizes. When you translate the virtual Raster to geotiff you merge the original files in to one. That is the reason in difference of file sizes.

Not the answer you're looking for? Browse other questions tagged or ask your own question.