[GRASS-dev] more interesting failure for reading fp_range of a NULL map

Markus Neteler neteler at osgeo.org
Wed Oct 1 07:51:50 PDT 2014

(back to an older yet new issue)

On Thu, Mar 7, 2013 at 10:11 PM, Glynn Clements
<glynn at 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 at Utente_1>

I would vote for an improvement of the error message since a common
user will not know what to do next.


More information about the grass-dev mailing list