2

Extracting raster values and creating new raster in QGIS? works great but there is no reduction in the new raster file size after raster calculator is run displaying just one or two classes (values) out of 8 classes... aerial tiffs segmented (using Orfeo) to capture tree canopies in this case.

Is there a tool that will complete this same process but ALSO result in a smaller file (tiff) size?

Dealing with 100mb tiffs that need to be reduced in size since they need to be converted to a shp.

100mb is apparently way too big for QGIS's polygonize tool as it hangs up in a seemingly infinite loop.

5
  • Just a blind guess, without seeing your data, but I'd bet that the problem is not file size, but rather the number of tiny polygons.
    – Micha
    Oct 25, 2016 at 13:14
  • Any suggestions on how to work around the issue of too many tiny polygons?
    – sirgeo
    Oct 26, 2016 at 2:36
  • What's the resolution of the raster? How many rows/columns? Any possibility to resample to a coarser resolution?
    – Micha
    Oct 26, 2016 at 12:47
  • Using smaller tiffs the Resample Nearest Neighbor (changing cell size from 1 to 4) works and reduces file size about 4x, but when attempting the same tool on the 100mb it spits out empty tiffs.... why would it do this? Losing a lot of detail using this method but it might be good enough if I can just get it to run correct on the large 100mb tiffs.
    – sirgeo
    Oct 27, 2016 at 5:09
  • A TIFF formated raster of 100MB isn't that big. Nearest Neighbor should work fine. BTW, if you set the cell size to 4x larger, then the output raster should be about 16x smaller... Don't know what else to suggest.
    – Micha
    Oct 27, 2016 at 8:55

1 Answer 1

2

The output from raster calculator produces a Data Type: Float32 - Thirty two bit floating point. You can use gdal_traslate to reduce the Data Type using -ot Byte, which will produce a Data Type of Byte - Eight bit unsigned integer. You need to specify the input original file and the out putput file, then use the pencil to customize the Data Type of the out put file and add -ot Byte, as follows:

enter image description here

gdal_translate -of HFA -ot Byte InputClass.tif OutputClass_8bit.tif

The output will be a reduced size raster file since you only want 2 classes.

8
  • Thanks for the help, I am still not having any reduction in tif file size though... i.imgur.com/cLmRRt1.png
    – sirgeo
    Oct 26, 2016 at 2:35
  • You need to do Raster calculation normally, then use the output image from raster calculator as input to the gdal_translate. You can find gdal_translate from 'Raster -> Conversion -> Translate'. Then you will find the tool used in my answer.
    – ahmadhanb
    Oct 26, 2016 at 2:54
  • I have tried this method doing the Raster Calculator then using the product tif from that into Translate and still end up with the same size output tif. Since I am using tiff files do I need to change HFA to tiff or tif? Not sure what I am missing here.
    – sirgeo
    Oct 27, 2016 at 5:02
  • Yes try to use -of GTiff instead of HFA, and see if it can solve your problem.
    – ahmadhanb
    Oct 27, 2016 at 5:16
  • 1
    The window options have changed in QGIS 3 -- the options for compression and data type are found under Advanced options that has to be clicked before those options are shown. Mar 28, 2019 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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