Change default grid format from NetCDF to GeoTIFF

NetCDF is the default grid format produced by GMT, but is there any way to change this?

I would like GMT always to create GeoTIFFs; not NetCDF. I.e., it would be great if I don’t need to specify =gdal:GTiff every time.

Is this possible? I didn’t see any obvious options for this in gmt.conf.

Not that I know off.

IO_GRIDFILE_FORMAT

I did not try it myself

How on earth did I miss that one. Thanks @mkononets, looks just right. Will test.

An important related parameter that does not seem to be configurable via gmt.conf is the default gridline grid registration (the -rp|g option). gdal that is used to produce geotiff files assumes grids are always is pixel-registered, which gmt apparently distinguish between gridline and pixel registration. This can result in lots of confusion (it used to confuse me a lot).

I see now that IO_GRIDFILE_FORMAT refers to grdconvert’s way of specifying the format. The identifier for gdal is `gd` for “Import/export through GDAL”. Not sure if this applies to the ‘new’ way of specifying output formats (I think grdconvert is ‘old’), e.g. grid.tif=gdal:GTIFF. I also suspect that IO_GRIDFILE_FORMAT only applies to grdconvert.

$ gmt set IO_GRIDFILE_FORMAT gd

$ gmt grdcut @earth_faa_01m -RSJ -Gsj_faa2.tif
grdconvert [ERROR]: Cannot find file (null)
grdblend [ERROR]: Unable to resample file (null).
grdcut [ERROR]: Cannot write with GDAL without knowing which driver to use.

$ gmt set IO_GRIDFILE_FORMAT gd:GTIFF

$ gmt grdcut @earth_faa_01m -RSJ -Gsj_faa2.tif
grdconvert [ERROR]: Cannot find file (null)
grdblend [ERROR]: Unable to resample file (null).
grdcut [ERROR]: Cannot write with GDAL without knowing which driver to use.

GMT is older than GDAL.

  • GMT default’s is grid registration (there was a time where we barely could find pixel-registered grids (mainly nc) in the wild
  • GDAL default is report everything as pixel registered. But it also has both mothers, though I’m yet to find a “Pixel is Point” product
  • When accessing GDAL library from GMT (which is different from using GDAL directly) we made the decision that, from within GMT the defaults should maintain (grid reg) and so we adjust whatever comes from GDAL LIB. At the time, that avoid a bad bug where Surfer grids, that don’t even have the concept of pixel registration, were reported with wrong limits.

What does the use of the gridline grid reg actually offer over the pixel reg?

Quarter-size corner grid cell, half-size edge cells… I am surely missing something important.

Note: (at least) grdmath picks up IO_GRIDFILE_FORMAT in gmt.conf, so it does not just apply to grdconvert.