Grdblend reports netCDF grid has no Z values

I am experimenting with grdblend to get a sense for how the weighting function works. To do this, I created two artificial grids in GRASS, each with identical spatial regions. The first grid has all z-values assigned as 100.0, the second 50.0. There are no null values in either grid.

I exported both to netCDF format using r.out.gdal. I notice that when I examine each grid using grdinfo, the z values are reported to be “Nan”, however when I use ‘grdinfo -L0’, I get the correct z values. Here is the contents of my blendfile: - 1.0 - 0.5

I run grdblend with this call:

grdblend weights.txt -R-63.998270/-62.432956/47.209846/48.133405 -I100e/100e -V

I get the following messages:

grdblend [WARNING]: netCDF grid information has zmin = zmax = NaN. Reset to 0/0.
grdblend [WARNING]: netCDF grid information has zmin = zmax = NaN. Reset to 0/0.

What do these messages mean? grdinfo shows that the output grid has a min/max of 83.333, so I suppose the program functioned correctly after all?

Thanks for any pointers,

~ Eric.

It looks like GRASS did not write zmin/zmax in the netcdf grids and that’s why grdinfo complains. When you use the -L option grdinfo actually scans the data but without it just reads the header.

Thanks, so I assume grdblend must also be reading the z-values directly from the input grids (and not relying on the netCDF header), because the blended z-values in the output grid make sense according to the weights I’m using. Is that correct?

grdblend certainly must read the array but some parts of if, while checking may rely on the header info.
You can easily make synthetic grids in GMT directly using grdmath. e.g.

$ gmt grdmath -R-63/-62/47/48 -I0.01 100 = g100.grd

$ gmt grdinfo g100.grd
g100.grd: Title: Produced by grdmath
g100.grd: Command: grdmath -R-63/-62/47/48 -I0.01 100 = g100.grd
g100.grd: Remark:
g100.grd: Gridline node registration used [Cartesian grid]
g100.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
g100.grd: x_min: -63 x_max: -62 x_inc: 0.01 name: x n_columns: 101
g100.grd: y_min: 47 y_max: 48 y_inc: 0.01 name: y n_rows: 101
g100.grd: z_min: 100 z_max: 100 name: z
g100.grd: scale_factor: 1 add_offset: 0
g100.grd: format: classic

Great, thanks for that tip. I’ve never used grdmath before, so I’ll have to check it out.