[GRASS-dev] Re: r.external

Glynn Clements glynn at gclements.plus.com
Fri Sep 12 20:59:02 EDT 2008


Markus Neteler wrote:

> > r.info -r pat_dtm_5m
> > WARNING: category support for [pat_dtm_5m] in mapset [PERMANENT] missing
> > min=nan
> > max=nan
> 
> I observe that 'f_range' remains empty:
> 
> GRASS 6.4.svn (patUTM):~ > l
> /home/neteler/grassdata/patUTM/PERMANENT/cell_misc/pat_dtm_5m
> total 52
> -rw-rw-r-- 1 neteler neteler   132 2008-09-12 14:07 gdal
> -rw-rw-r-- 1 neteler neteler     0 2008-09-12 14:07 f_range
> -rw-rw-r-- 1 neteler neteler     5 2008-09-12 14:07 f_quant
> -rw-rw-r-- 1 neteler neteler    28 2008-09-12 14:07 f_format
> -rw-rw-r-- 1 neteler neteler 39928 2008-09-12 22:16 histogram

Odd.

> Could the file be populated using GDAL functions?

It is:

304	    info->range[0] = GDALGetRasterMinimum(hBand, &bGotMin);
305	    info->range[1] = GDALGetRasterMaximum(hBand, &bGotMax);
306	    if(!(bGotMin && bGotMax))
307		GDALComputeRasterMinMax(hBand, !exact_range, info->range);

460		struct FPRange fprange;
461		fprange.min = info->range[0];
462		fprange.max = info->range[1];
463		G_write_fp_range(output, &fprange);
464		write_fp_format(output, info);
465		write_fp_quant(output);

The fact that the f_quant and f_format files are being written implies
that G_write_fp_range() is being called, but is writing an empty file.

Hmm; the -r flag won't help if GDAL is reporting a stored range. But
r.support.stats should fix that.

Is it possible that something is causing GDAL to "see" NaNs?

Maybe the presence of NaNs interferes with the range calculation. As
all inequalities return false for NaN, code such as:

	#define MIN(a,b) ((a) < (b) ? (a) : (b))
	#define MAX(a,b) ((a) > (b) ? (a) : (b))

	for (i = 0; i < n; i++) {
	    min = MIN(min, x[i]);
	    max = MAX(max, x[i]);
	}

will set both min and max to NaN if even a single x[i] is NaN.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list