Creating a zero-level grid

Very likely, this has a simple answer… how do I inform GMT that a 1-degree square region is “geographic?” I need to create a zero-level grid (i.e., all z = 0).

This command

gmt grdmath -R3/4/51/52 -I1s/1s 0 = t.grd

yields this response:

grdmath [WARNING]: Unit s is ignored as the x-axis is not geographic
grdmath [WARNING]: Unit s is ignored as the y-axis is not geographic

And, when checking that the grid was made with a one arcsec increment, this results:

> gmt grdinfo t.grd
t.grd: Title: Produced by grdmath
t.grd: Command: grdmath -R3/4/51/52 -I1s/1s 0 = t.grd
t.grd: Remark: 
t.grd: Gridline node registration used [Cartesian grid]
t.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
t.grd: x_min: 3 x_max: 4 x_inc: 1 name: x n_columns: 2
t.grd: y_min: 51 y_max: 52 y_inc: 1 name: y n_rows: 2
t.grd: v_min: 0 v_max: 0 name: z
t.grd: scale_factor: 1 add_offset: 0
t.grd: format: classic

I’ve tried several variants (-fg, and +d on the -R spec), and nothing seems to get past this. Must be something I missed.

We must have had some regression here. -I1s works but -I1s/1s gives the problem above. So unless you want unequal spacing then use -I1s for now and we will look at this problem.

Fixed in the repo: https://github.com/GenericMappingTools/gmt/pull/5036

Thank you, Paul, for confirming that I wasn’t crazy! I was using -I1s/1s because there will be cases closer to the poles where using -I2s/1s, etc. will be needed. I’ve pulled the latest version.

At the root of my issue is that gmtinfo, when applied to a tif file, seems to report back mixed units in the -I specification. For example:

> gmt grdinfo -I /xtdata/copr_glo-30_dem/Copernicus_DSM_COG_10_N52_00_E004_00_DEM/Copernicus_DSM_COG_10_N52_00_E004_00_DEM.tif
-I0.000416667/1s

Once I have the -I specification, it won’t work with gmtmath to create a zero level grid.

The real problem is that I have to paste together three grids to form an “L” shaped grid, but grdpaste won’t do that, so I have to create a zero-level fourth grid to make the final grid ssquare.