Convert geotiff to grd file


Does someone have information on how can I convert a bathymetric 250m data in Geotiff with utm26 projection, to .grd in latitude and longitude coordinates? I was trying the following two commands, but it does not work.

gmt grdconvert CG-250m-utm26.tif -GCG_250m.grd -V
gmt mapproject CG_250m.grd -Ju -C -I -F -V > test.grd


Not 100% sure, but try gmt grdconvert CG-250m-utm26.tif -GCG_250m.grd -V -Ju+26/1:1 -F -C -I

Or try gdalwarp -s_src EPSG:26632 -t_src EPSG:4326 -of GMT infile outfile. Assuming from utm26 wgs84 to wgs84.

1 Like

No. There is no such a thing as GMT grids (well there are those old native binary grids but GDAL knows nothing about them). Just give the output name with a .nc extension to select netCDF. The alternative is use grdproject.

The distinction between convert (we convert formats) and (re)project must be understood.

Some GDAL builds have a “GMT” raster driver that is a recent netCDF. Not all builds have it though. I used to use gdal_translate -of GMT all the time to convert other formats to a GMT netCDF.

gdalinfo --formats | grep GMT
returns nothing for me. There used to be a GMT netCDF driver but that was the old GMT3 netCDF grids that were made up with a vector instead of a matrix. That diver was dropped in the driver cleaning that GDAL performed 1 or 2 years ago.

I used to use the GDAL from MacPorts that did include a “GMT” raster driver. Now MacPorts no longer builds GDAL correctly because the maintainer has to fix something for newer compilers. The gdal that can be installed from conda-forge does not include that driver. I must have been using the older GDAL.

I’ve never heard about another GMT raster driver and the current GDAL drivers list does not mention any GMT driver

I have temporarily switched to homebrew because of this. I cannot understand how macports can release a goal that does not build…

This is how it looks on my Debian 11 machine:

 $ gdalinfo --formats | grep -i gmt
  GMT -raster- (rw): GMT NetCDF Grid Format

$ gdalwarp --version
GDAL 3.2.2, released 2021/03/05

Why does this driver exist if it’s not listed in the driver list?
And should the GMT driver be avoided? I.e. use netCDF?

Yes. If an old GDAL has a GMT driver it is the ancient GMT3 1-D vector format that nobody should ever use.

Why would they put a vector driver under rasters? Ref. GMT -raster- (rw): GMT NetCDF Grid Format. Or am I misunderstanding the format?

GMT3 stored 2-D grids as one long 1-D vector, hence the GMT “raster” format code. Now obsolete.

1 Like

Got it. Thanks Paul.

Thanks. I got using a webpage. I am trying now to plot a spatial-temporal graphic of seismicity below the map. I am using the psbasemap, however, the plot its not going out of the map. For example, I used -Y-18.5. It does shows the window. However, if I decrease to -Y-6, the new psbasemap is shown inside the map window. Do you know why? Here is the command of the spatial-temporal plot:

gmt psbasemap -R-35.75/-29/1950-1-1T/2022-1-1T -JX25/17 -V -O -K -Xc -Y-18.5 -Bya5Yf1Y -Bxa1.f.5 -BWSne >> $fig


I just compiled and installed bleeding edge gdal, and there’s no GMT-driver:

$ gdalinfo --formats | grep -i gmt
$ gdalinfo --version
GDAL 3.7.0dev-6e07e44620, released 2023/03/06 (debug build)

Maybe the version shipped with Debian 11 is the pre-cleanup that @Joaquim mentioned.

I will be grateful for any help. I am not getting to solve this problem. :frowning:

You can see attached the problem. I do not know why the spatial-temporal plot is inside the map area. I used this command:

gmt psbasemap -R-35.75/-29/1950-1-1T/2022-1-1T -JX25 -V -X0 -Gwhite -Y-18.5 --FONT_LABEL=12p,Helvetica,black --FORMAT_GEO_MAP=ddd.x -Ba1.f.5/a5Yf1YWSne -K -O >> $fig

Cannot guess the rest of your script so presumably wrong shifts given size of maps

The spatial-temporal plot should be plotting in a separate figure below the map.
It shows that message:

psbasemap [INFORMATION]: Constructing the basemap
psbasemap [INFORMATION]: Linear projection implies x-axis distance exaggeration relative to the y-axis by a factor of 2.02012e-09
psbasemap [INFORMATION]: Map scale is 0.00027 km per cm or 1:27.