[GRASS-dev] quickest way to test whether a raster contains any non-null values in the current computational region ?

Markus Neteler neteler at osgeo.org
Fri Oct 19 07:48:49 PDT 2018


On Fri, Oct 19, 2018 at 4:04 PM Moritz Lennert
<mlennert at club.worldonline.be> wrote:
> On 19/10/18 15:48, Michel Wortmann wrote:
> > Hi Moritz,
> > How about this:
> >
> > info = grass.parse_command('r.univar', map='raster_xyz', flags='g')
> > print(int(info['n']), int(info['null_cells']))
>
> Thanks !
>
> Yes, this is one option. I was wondering if there was any faster option
> than actually having to read the map in the whole region with r.univar,
> but probably there isn't.

For the full map there is (note the difference between cells= and n=) [1]:

r.info -s elev_srtm_30m_filt
cells=225000
n=222558
min=50.6936492919922
max=189.817504882812
mean=114.733047915657
stddev=20.6650778315329
sum=25534757.6780128

but AFAIK not when the computational region differs from that of the full map.

markusN

[1] https://grass.osgeo.org/grass74/manuals/r.fillnulls.html#example


More information about the grass-dev mailing list