Hi all,
What would be the quickest way to test whether a raster contains any non-null values in the current computational region ?
And the correlary: what would be the quickest way to test whether a raster contains any null values in the current computational region ?
This will be applied in Python, so if there are any special Python functions, these are welcome, too.
Moritz
Hi Moritz,
How about this:
info = grass.parse_command(‘r.univar’, map=‘raster_xyz’, flags=‘g’)
print(int(info[‘n’]), int(info[‘null_cells’]))
Michel
On 19 Oct 2018, at 15:36, Moritz Lennert <mlennert@club.worldonline.be> wrote:
Hi all,
What would be the quickest way to test whether a raster contains any non-null values in the current computational region ?
And the correlary: what would be the quickest way to test whether a raster contains any null values in the current computational region ?
This will be applied in Python, so if there are any special Python functions, these are welcome, too.
Moritz
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev
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.
Moritz
On Fri, Oct 19, 2018 at 4:04 PM Moritz Lennert
<mlennert@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
On Fri, Oct 19, 2018 at 11:04 AM, Moritz Lennert <mlennert@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.
Moritz
_____________________________
Moritz,
I am unable to check at the moment, but I thought off the top of my head that r.mapcalc might have a function to report this info?
~ Eric
On Fri, Oct 19, 2018 at 4:04 PM Moritz Lennert <mlennert@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.
You need a module that reads the whole map, and the fastest way to get the number of non-null values is most probably r.univar -g, as mentioned by Michel Wortmann.
Markus M
Moritz
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev