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.

sirgeo
  • 2,029
  • 5
  • 33
  • 43
  • 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 '16 at 13:14
  • Any suggestions on how to work around the issue of too many tiny polygons? – sirgeo Oct 26 '16 at 02:36
  • What's the resolution of the raster? How many rows/columns? Any possibility to resample to a coarser resolution? – Micha Oct 26 '16 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 '16 at 05: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 '16 at 08:55

1 Answers1

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.

ahmadhanb
  • 40,826
  • 5
  • 51
  • 105
  • Thanks for the help, I am still not having any reduction in tif file size though... http://i.imgur.com/cLmRRt1.png – sirgeo Oct 26 '16 at 02: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 '16 at 02: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 '16 at 05:02
  • Yes try to use -of GTiff instead of HFA, and see if it can solve your problem. – ahmadhanb Oct 27 '16 at 05:16
  • Still having issues .... "Error 4" is produced unless the pencil is clicked a second time after entering the gdal script... when using the "pencil clicked twice" method it will run but results in the same size tiffs... what am i not doing correct here? http://i.imgur.com/MwhQYXq.png – sirgeo Oct 27 '16 at 15:07
  • You didn't add -ot Byte after -of GTiff – ahmadhanb Oct 28 '16 at 01:12
  • Is this still possible? When I open Translate (convert format) under GDAL in the processing toolbox, I do not see the same options in QGIS 3.4. Is it the version that has changed or I am accessing it from the wrong route? – user3386170 Mar 28 '19 at 13:31
  • 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. – user3386170 Mar 28 '19 at 14:31