I need to plot bathymetry map of my study region and need to convert the .srtm to .xyz or .grd format to use GMT. I tried to do this with grdraster and xyz2grd, but got wrong results. I found that there is srtm2grd command in Linux but I do not have it in my commands. the data are in the following address: ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/data/
3 Answers
NOTE: This is not the solution to the question in the title but it solves the problem described in the question's text.
Alternative solution
I would download the netCDF
files from the grd
directory instead of the srtm
files from the data
directory on the FTP server. The netCDF
files can directly be plotted by GMT.
Example
Based on this file: e020n40.nc
#!/bin/bash
outfile=pic.ps
infile=e020n40.nc
invar=z
colorfile=colors.cpt
gmt makecpt -Cviridis -D -T-5200/2400/400 > ${colorfile}
gmt psbasemap -R20/60/-10/40 -JM18 -B4/4"NSEW" -X+1.5c -P -K > ${outfile}
gmt grdimage ${infile}?${invar} -R -J -C${colorfile} -O -K >> ${outfile}
gmt pscoast -J -R -Di -W1,black -O >> ${outfile}
output (pic.ps
imported into GIMP v2.8.22 in 60 dpi resolution and with strong antialiasing):
QGIS does it easily. open the NETCDF (or whatever format the SRTM sits in) by add raster right click on the menu item and select export choose the file format as .xyz
DONE!
thanks everybody for your comments and reply I used the grdconvert command in GMT to convert the mentioned .srtm to .grd format.
-
$\begingroup$ Please provide some example code on how the conversion works. This might help other users having the same problem. Thanks. $\endgroup$ Apr 5, 2020 at 12:59
.xyz
format for GMT doesn't need cartesian coordinates as requested in Converting from longitude\latitude to Cartesian coordinates. The GMT xyz Format describes the elevation (z
) above a reference ellipsoid at a specific location at the surface of the reference ellipsoid (x,y
).x
andy
are expected to be longitude and latitde coordinates in degree East and degree West. Thus,xyz
rather meanslon-lat-z
. $\endgroup$