<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.19597"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial>Hi Pedro,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial>using your suggestion I came up with this command
:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial>gdal_translate -co COMPRESS=DEFLATE -co PREDICTOR=2 -co
ZLEVEL=9 -ot Byte -of GTiff -tr 1.0 -1.0 -a_nodata 0 input.tif
output.tif</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020><FONT color=#000080
size=2 face=Arial>and got the 5GB file cut result raster from before down to 43
MB !</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020></SPAN><SPAN
class=415451023-12062020></SPAN><FONT face=Arial><FONT color=#000080><FONT
size=2>T<SPAN class=415451023-12062020>h</SPAN><SPAN
class=415451023-12062020>a</SPAN><SPAN
class=415451023-12062020>nks</SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><SPAN class=415451023-12062020></SPAN><SPAN
class=415451023-12062020></SPAN><FONT face=Arial><FONT color=#000080><FONT
size=2>K<SPAN
class=415451023-12062020>arsten</SPAN></FONT></FONT></FONT><BR></DIV>
<DIV lang=en-us class=OutlookMessageHeader dir=ltr align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Pedro Venāncio
[mailto:pedrongvenancio@gmail.com] <BR><B>Sent:</B> Friday, June 12, 2020
13:19<BR><B>To:</B> karsten<BR><B>Cc:</B> QGIS User<BR><B>Subject:</B> Re:
[Qgis-user] clip raster by mask layer (gdalwarp with -cutline option) enormously
bloats file size<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>
<DIV>Hi Karsten,</DIV>
<DIV><BR></DIV>
<DIV>First you have to ensure that the output data type is also Byte:</DIV>
<DIV>-ot Byte</DIV>
<DIV><BR></DIV>
<DIV>Second, your original raster must be some kind of compression. You can see
it with gdalinfo. So, you need to apply compression to the output file, for
instance with:
<P style="WHITE-SPACE: pre-wrap; MARGIN: 0px; TEXT-INDENT: 0px">-co
COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9</P>
<P style="WHITE-SPACE: pre-wrap; MARGIN: 0px; TEXT-INDENT: 0px"><BR></P>
<P style="WHITE-SPACE: pre-wrap; MARGIN: 0px; TEXT-INDENT: 0px">Best
regards,</P>
<P style="WHITE-SPACE: pre-wrap; MARGIN: 0px; TEXT-INDENT: 0px">Pedro
Venāncio</P>
<P
style="WHITE-SPACE: pre-wrap; MARGIN: 0px; TEXT-INDENT: 0px"><BR></P></DIV></DIV><BR>
<DIV class=gmail_quote>
<DIV class=gmail_attr dir=ltr>karsten <<A
href="mailto:karsten@terragis.net">karsten@terragis.net</A>> escreveu no dia
sexta, 12/06/2020 ą(s) 21:09:<BR></DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><U></U>
<DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>Hi All,</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>I have a large *.tif raster
data set ( 92000 * 69000 cells of one meter, projection EPSG:25832 - ETRS89 /
UTM zone 32N )<BR>It contains integer values 1 to 20 and has a file size
of about 100 MB in "Byte - Eight bit unsigned integer"
format. <BR>Now the result is a rectangle and I wanted to cut it down to
the area of interest (via cutline gdal option) using a shape polygon file
(with one continuous polygon inside) to and set all values outside the area of
interest of that rectangle to NULL values (for example setting 0 as
NULL data values). I used the QGIS ( QGIS v 3.12 on windows) Menu RASTER
> Extraction > Clip Raster by mask Layer which is based on
gdalwarp.<BR></SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>That is when I am
running into the problem that the 'cut' file size increases enormously and I
ended up wit 50 times bigger file ( 5 GB size ! ) when I was actually
expecting a smaller file size than before.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>I have not really
an idea why the file becomes so enormously bloated. The same is the
cass when I try gdalwarp directly on the command line or when using the QGIS
Raster calculator or any other method I tried so far.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>How can I manage to get a
smaller file size ( aka the 100 MB file size I started of with ) and which
tools or formats are recommended to achieve this ?</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>Cheers</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN>Karsten</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN></SPAN></FONT> </DIV>
<DIV><SPAN
style='FONT-SIZE: 11pt; FONT-FAMILY: "Verdana","sans-serif"'>Karsten
Vennemann<BR></SPAN><SPAN
style='FONT-SIZE: 9pt; FONT-FAMILY: "Verdana","sans-serif"'><SPAN
style="COLOR: rgb(0,50,100)"><A
title="http://www.terragis.net/
blocked::http://www.terragis.net/"
href="http://www.terragis.net" target=_blank><FONT
title=http://www.terragis.net/
color=#0000ff>www.terragis.net</FONT></A></SPAN></SPAN><U></U><U></U><U></U></DIV>
<DIV align=left>
<DIV align=left><FONT color=#000080 size=2
face=Arial></FONT> </DIV></DIV></DIV>_______________________________________________<BR>Qgis-user
mailing list<BR><A href="mailto:Qgis-user@lists.osgeo.org"
target=_blank>Qgis-user@lists.osgeo.org</A><BR>List info: <A
href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel=noreferrer
target=_blank>https://lists.osgeo.org/mailman/listinfo/qgis-user</A><BR>Unsubscribe:
<A href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel=noreferrer
target=_blank>https://lists.osgeo.org/mailman/listinfo/qgis-user</A></BLOCKQUOTE></DIV></BODY></HTML>