Hi Moritz,

On Fri, Jun 28, 2019 at 11:56 AM Moritz Lennert <
[email protected]> wrote:
>
> On 28/06/19 11:10, Stefan Blumentrath wrote:
> > Hi Moritz,
> >
> > Did you consider r.stats -N for checking for NULL values within the
masked area, like:
> > r.stats -N input=tile,MASK
> > if there is *|1 in the output you have NULL cells in the tile...

the fastest way to get the total number of cells and the number of non-NULL
cells, ignoring any MASK, is r.info -s, e.g.
cells=4917486    <-- total number of cells
n=4873149         <-- number of non-NULL cells

these numbers are stored in metadata and independent of the current region
>
> Nice trick, didn't actually know about the -N flag...
>
> >
> > For filling NULLs with a given value you could do:
> > r.mapcalc expression=tile_filled=if(MASK,if(isnull(tile),1,tile),null())

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:
r.mapcalc expression="tile_filled = if(isnull(mymask) != 0 and mymask != 0,
if(isnull(tile), 1, tile), null())"

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"

Markus M

>
> Duh, now that I see this, it seems quite obvious.
>
> Thanks Stefan !
>
> (And thanks Ken for your ideas)
>
> Moritz
>
> _______________________________________________
> grass-dev mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/grass-dev
_______________________________________________
grass-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to