In the same way as there is a pixel based function to assess a
NULL pixel value, it would be very interesting to have a
function to test an all NULL raster map status.
see 'r.info -r' for overall map, or r.univar for within-region window.
In the same way as there is a pixel based function to assess a
NULL pixel value, it would be very interesting to have a
function to test an all NULL raster map status.
see ‘r.info -r’ for overall map, or r.univar for within-region window.
That is a module level way, i was wondering about a C function like the one
below:
/*A fatal error when NULL map*/
if(Rast_is_null_map(mapname, mapset)<0){
G_fatal("Input file has only null values");
} else {
/* do some useful thing */
}
1. In general, there's nothing erroneous about an all-null input map.
Most modules should treat such a map the same as any other map.
2. Whether or not a map contains any non-null cells is usually
irrelevant. What matters is whether there are any non-null cells
within the current region (and after any mask has been applied). And
this can't be determined without actually reading the map.
So given that the map has to be read anyhow, the module should simply
operate normally, keeping track of whether any non-null values have
been read so that any final calculation doesn't make assumptions about
e.g. the count of non-null cells being non-zero, having a valid
minimum and maximum, etc.
If, for a specific module, all-null inputs are common, it might be
worth checking whether the range has null minimum and/or maximum
(they'll be either both null or both non-null) as an optimisation. But
I would expect this to be the exception rather than the rule.
On Thu, Mar 7, 2013 at 10:11 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:
Yann Chemin wrote:
That is a module level way, i was wondering about a C function like the one
below:
/*A fatal error when NULL map*/
if(Rast_is_null_map(mapname, mapset)<0){
G_fatal("Input file has only null values");
} else {
/* do some useful thing */
}
1. In general, there's nothing erroneous about an all-null input map.
Most modules should treat such a map the same as any other map.
2. Whether or not a map contains any non-null cells is usually
irrelevant. What matters is whether there are any non-null cells
within the current region (and after any mask has been applied). And
this can't be determined without actually reading the map.
So given that the map has to be read anyhow, the module should simply
operate normally, keeping track of whether any non-null values have
been read so that any final calculation doesn't make assumptions about
e.g. the count of non-null cells being non-zero, having a valid
minimum and maximum, etc.
If, for a specific module, all-null inputs are common, it might be
worth checking whether the range has null minimum and/or maximum
(they'll be either both null or both non-null) as an optimisation. But
I would expect this to be the exception rather than the rule.
On G+ a user brought up this issue:
On Tue, Sep 30, 2014 at 11:20 AM, xxx wrote:
r.watershed generates this error:
WARNING: Unable to read fp range file for <accumulation@Utente_1>
I would vote for an improvement of the error message since a common
user will not know what to do next.