I need to cut a raster layer (size 500 MB about) using a vector mask.

Going to Raster -> Extraction -> Clipper and using a vector mask in the same coordinate system of the raster, QGIS produces a .tiff raster bigger than the original raster (about 1.5 GB) and without the two and .prj file.

I cannot explain this: is there a way to have a clipped raster smaller than the original one and with the two and .prj associated files?


The clipped raster is an uncompressed GeoTIFF (no projection file needed), so you should edit the gdalwarp string manually in the Clipper window to set the compression method (and other useful options). For instance:

gdalwarp -q -cutline C:/Geodata/potenza.shp -crop_to_cutline -tr 10.0 10.0 C:/Geodata/Sentinel-2/RGB.tif C:/Geodata/Sentinel-2/RGB_clipped.tif -co "TILED=YES" -co "COMPRESS=DEFLATE" -co "INTERLEAVE=BAND" -co "BLOCKXSIZE=256" -co "BLOCKYSIZE=256"
| improve this answer | |

It depends a lot on your input raster if the output is smaller or larger. Qgis uses the tiff-format as standard, because it is an open format. It also uses no compression as standard for interoperability reasons with other software.

When you input for example an .ecw file you will end up with a file that is often 100 times larger. First of all .ecw is not loss-less, as the standard .tiff is. Second point is that the .ecw is proprietary. When you install Qgis with the support for this type you agree the license agreement and can read this format. But you can´t create one without buying the special software for this. That is the case with many other formats.

You can get a smaller .tiff file when setting in the clip tool in the small field in the lower area the gdalwarp options to a different compression. For example:

gdalwarp -q -cutline cutline_file.shp -crop_to_cutline -tr 1.0 1.0 -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 input.tif output.tif

Different options are possible, like LZW compression or JPEG (smallest file, but lossy). Not all programs can understand all compressions is a point that might be a problem when exporting it to use within other software.

You get only one file in the output as Qgis uses here the Geotiff standard which puts the coordinate reference in the header of the file itself and not in an extra file.

| improve this answer | |

The default raster type is 32-bit Float. If you original raster was an intger type, this explains the inflation in size.

As the Clipper tool is basically the GDAL Clip raster by mask tool, I suggest you use that tool from the Processing Toolbox, where you can set the export type.

enter image description here enter image description here

| improve this answer | |

I didn't check myself, but I suppose you could possibly edit the image file with graphical files software (Paint, PaintNET, Adobe Photoshop…) and just use save as… option and set different format and maybe change other saving options.

| improve this answer | |

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.