<div dir="ltr">Hi Moritz,<br><br>On Fri, Jun 28, 2019 at 11:56 AM Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>><br>> On 28/06/19 11:10, Stefan Blumentrath wrote:<br>> > Hi Moritz,<br>> ><br>> > Did you consider r.stats -N for checking for NULL values within the masked area, like:<br>> > r.stats -N input=tile,MASK<br>> > if there is *|1 in the output you have NULL cells in the tile...<br><div><br></div><div>the fastest way to get the total number of cells and the number of non-NULL cells, ignoring any MASK, is <a href="http://r.info">r.info</a> -s, e.g.</div><div>cells=4917486    <-- total number of cells<br>n=4873149         <-- number of non-NULL cells</div><div><br></div><div>these numbers are stored in metadata and independent of the current region<br></div><div>></div>> Nice trick, didn't actually know about the -N flag...<br>><br>> ><br>> > For filling NULLs with a given value you could do:<br>> > r.mapcalc expression=tile_filled=if(MASK,if(isnull(tile),1,tile),null())<br><div><br></div><div>in this case, I recommend to create a custom mask that is not named MASK but e.g. mymask, and the r.mapcalc expression probably needs some modification regarding NULL values in mymask:<br></div><div>r.mapcalc expression="tile_filled = if(isnull(mymask) != 0 and mymask != 0, if(isnull(tile), 1, tile), null())"</div><div><br></div><div>The reason is that if(MASK, ...) should return NULL if MASK is NULL which is not what you want, you want " if MASK is not NULL"</div><div><br></div><div>Markus M</div><div><br></div><div>></div>> Duh, now that I see this, it seems quite obvious.<br>><br>> Thanks Stefan !<br>><br>> (And thanks Ken for your ideas)<br>><br>> Moritz<br>><br>> _______________________________________________<br>> grass-dev mailing list<br>> <a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-dev">https://lists.osgeo.org/mailman/listinfo/grass-dev</a></div>