1
$\begingroup$

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/

$\endgroup$
  • $\begingroup$ srtm comes as decimal lat/lon with height values above or below reference ellipsoid. Converting lat/lon to cartesian (e.g.wgs84) is straight forward. e.g. stackoverflow.com/questions/1185408/…. Extrude height along ellipsoid surface normals, not centric normals. $\endgroup$ – a_donda Mar 31 at 14:04
  • 1
    $\begingroup$ suggest moving this to Geographic Information Systems stack ex change $\endgroup$ – haresfur Apr 1 at 1:01
  • 1
    $\begingroup$ @a_donda The .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 and y are expected to be longitude and latitde coordinates in degree East and degree West. Thus, xyz rather means lon-lat-z. $\endgroup$ – daniel.heydebreck Apr 1 at 8:00
  • 1
    $\begingroup$ I see. I wrote a conversion routine for srtm data for my terrain renderer to convert them from geodetic to cartesian (it's just a few lines in C++) to render them in opengl. Wasn't aware that .xyz is a format, thought it was just meant as a paraphrase for cartesian. It takes longer to install GDAL (not mentioning learn the command syntax) than to write the method in an ellipsoid class. I wouldn't trust GDAL on srtm v4.1 data when there's a manual method :-) $\endgroup$ – a_donda Apr 1 at 9:53
  • 1
    $\begingroup$ @a_donda Thanks for the background. "I wouldn't trust GDAL on srtm v4.1 data when there's a manual method :-) " => Than better by hand :-D $\endgroup$ – daniel.heydebreck Apr 1 at 14:58
4
$\begingroup$

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):

enter image description here

| improve this answer | |
$\endgroup$
1
$\begingroup$

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!

| improve this answer | |
$\endgroup$
0
$\begingroup$

thanks everybody for your comments and reply I used the grdconvert command in GMT to convert the mentioned .srtm to .grd format.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Please provide some example code on how the conversion works. This might help other users having the same problem. Thanks. $\endgroup$ – daniel.heydebreck Apr 5 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.