<div dir="ltr"><div><div><div><div><br><br>On Tue, Jan 3, 2017 at 6:08 PM, Markus Neteler <<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>> wrote:<br>><br>> Hi,<br>><br>> while hunting for more GBs on my local disk I found many raster maps<br>> with a still uncompressed NULL files (no surprise since the optional<br>> new NULL compression was introduced in 7.2.0).<br>><br>> As an example - EU DEM25m:<br>><br>> uncompressed NULL file:<br>> 6000000000 Apr 13  2016 ./eu_laea/PERMANENT/cell_misc/eu_dem25/null<br>><br>> compressed NULL file:<br>> 32108798 Jan  3 15:09 eu_laea/PERMANENT/cell_misc/eu_dem25/nullcmpr<br>><br>> Ratio:<br>> > 32108798 / 6000000000<br>> [1] 0.005351466<br>><br>> ... quite an improvement :-)<br>><br>> Having tons of raster maps here I thought of running r.null over all<br>> raster maps. In general it is:<br>><br>> export GRASS_COMPRESS_NULLS=1<br>> r.null -z myrastermap<br>><br>> Attached a patch which adds a second line of output to "r.compress -p<br>> myrastermap" in order to check the actual compression state of a map:<br>><br>> r.compress -p eu_dem25<br>> <eu_dem25> is compressed (method 2: ZLIB). Data type: FCELL<br>> <eu_dem25> has an uncompressed NULL file<br>><br>> After compression it looks like this:<br>><br>> r.compress -p eu_dem25<br>> <eu_dem25> is compressed (method 2: ZLIB). Data type: FCELL<br>> <eu_dem25> has a compressed NULL file<br>><br>> Now, how to use that:<br>><br>> # all in one (check if NULL is compressed, if no, do it otherwise don't touch):<br>> r.compress -p eu_dem25 2>&1 | grep uncompressed && r.null -z eu_dem25<br>><br>> Questions:<br>> I believe that an additional -g flag for shell style printing would be<br>> useful as well).<br>> Maybe with a -g flag no need to use the stderr redirect?<br>> Any better ideas here? (if yes, feel free to submit to SVN for testing)<br><br></div>I have added your changes and a new shell style option to trunk in r70337. Note that this is not standard shell style because the module accepts several input maps, thus compression info is written to stdout as one line per input map. The format is<br>input map name|data type|name of data compression method|NULL file compression<br></div>e.g.<br></div>eu_dem25|FCELL|ZLIB|NO<br></div>or<br><div><div><div><div>eu_dem25|FCELL|BZIP2|YES<br><br>><br>><br>> ################<br>> Since r.null -z doesn't do anything useful if GRASS_COMPRESS_NULLS is<br>> not set I have tried (!) to add a G_message() to tell the user if that<br>> variable is set or not.<br>> r.null -z eu_dem25<br>> The GRASS_COMPRESS_NULLS environment variable is currently set<br>> 6%...<br>><br>> But it *always* tells that it is set, so my getenv() parsing is wrong.<br>> Can anyone help please? Also attached...<br><br></div><div>Try trunk r70338. This also fixes removal of a compressed NULL file: the file name is nullcmpr, not null2<br></div><div><br></div><div>Markus M<br></div><div><br></div></div></div></div></div>