<p><strong>NOTE:</strong> <em>This is not the solution to the question in the title <strong>but it solves the problem described in the question's text</strong>.</em></p>

<h1>Alternative solution</h1>

<p>I would download the <code>netCDF</code> files from the <code>grd</code> directory instead of the <code>srtm</code> files from the <code>data</code> directory on the FTP server. The <code>netCDF</code> files can directly be plotted by GMT.</p>

<h1>Example</h1>

<p>Based on this file: <a href="ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/grd/e020n40.nc" rel="nofollow noreferrer">e020n40.nc</a></p>

<pre><code>#!/bin/bash

outfile=pic.ps
infile=e020n40.nc
invar=z
colorfile=colors.cpt

gmt makecpt -Cviridis -D -T-5200/2400/400 &gt; ${colorfile}

gmt psbasemap -R20/60/-10/40 -JM18 -B4/4"NSEW" -X+1.5c -P -K &gt; <span class="math-container">${outfile}
gmt grdimage $</span>{infile}?<span class="math-container">${invar} -R -J -C$</span>{colorfile} -O -K &gt;&gt; <span class="math-container">${outfile}
gmt pscoast -J -R -Di -W1,black -O &gt;&gt; $</span>{outfile}
</code></pre>

<p>output (<code>pic.ps</code> imported into GIMP v2.8.22 in 60 dpi resolution and with strong antialiasing):</p>

<p><a href="https://i.sstatic.net/L894w.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/L894w.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2020-04-01T14:57:31.193Z
2020-04-01T14:57:31.193Z
daniel.heydebreck
<p>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</p>

<p>DONE!</p>

CC BY-SA 4.0
2020-04-04T20:57:51.633Z
2020-04-04T20:57:51.633Z
yair suari
<p>thanks everybody for your comments and reply
I used the  <em>grdconvert</em> command  in GMT to convert the mentioned .srtm to .grd format. </p>

CC BY-SA 4.0
2020-04-05T12:59:51.500Z
Please provide some example code on how the conversion works. This might help other users having the same problem. Thanks.
daniel.heydebreck
CC BY-SA 4.0
2020-04-05T07:25:39.350Z
2020-04-05T07:25:39.350Z
mehdi shokati
<p>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: <a href="ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/data/" rel="nofollow noreferrer">ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/data/</a></p>

CC BY-SA 4.0
2020-04-01T01:01:34.210Z
suggest moving this to Geographic Information Systems stack ex change
haresfur
CC BY-SA 4.0
2020-04-01T07:14:04.090Z
I would use [`gdal_translate` of GDAL](https://gdal.org/programs/gdal_translate.html#gdal-translate) to convert the SRTM file into a format of your choice. GDAL has a driver for [SRTM files v1.0 and 3.0](https://gdal.org/drivers/raster/srtmhgt.html). If I were in your situation, I would create a NetCDF file because I know how to handle them and GMT can read them. GDAL can even create a [GMT-compliant NetCDF file](https://gdal.org/drivers/raster/gmt.html). Not sure what that means ... . I don't have time in the moment to try it myself.
daniel.heydebreck
CC BY-SA 4.0
2020-04-01T07:28:58.067Z
I wouldn't do the conversion by hand if there were trusted tools like GDAL. Converting  elevation data between different Earth shapes by hand might be easy from a purely technical/mathematical perspective. But, there might be introduced some errors if ones has no idea about different reference systems and Earth shapes ... .
daniel.heydebreck
CC BY-SA 4.0
2020-04-01T08:00:15.800Z
@a_donda The `.xyz` format for GMT doesn't need cartesian coordinates as requested in [Converting from longitude\latitude to Cartesian coordinates](https://stackoverflow.com/questions/1185408/converting-from-longitude-latitude-to-cartesian-coordinates#1185413). 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`.
daniel.heydebreck
CC BY-SA 4.0
2020-04-01T14:58:33.590Z
@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
daniel.heydebreck
<mapping><gis>
convert .srtm to xyz ord grd
mehdi shokati
# convert .srtm to xyz ord grd

(Asked by: username_0 on 2020-03-31)

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/>

**Tags:** mapping, gis

> **Comments:**
> **username_1**: suggest moving this to Geographic Information Systems stack ex change  
> **username_2**: I would use [`gdal_translate` of GDAL](https://gdal.org/programs/gdal_translate.html#gdal-translate) to convert the SRTM file into a format of your choice. GDAL has a driver for [SRTM files v1.0 and 3.0](https://gdal.org/drivers/raster/srtmhgt.html). If I were in your situation, I would create a NetCDF file because I know how to handle them and GMT can read them. GDAL can even create a [GMT-compliant NetCDF file](https://gdal.org/drivers/raster/gmt.html). Not sure what that means ... . I don't have time in the moment to try it myself.  
> **username_2**: I wouldn't do the conversion by hand if there were trusted tools like GDAL. Converting  elevation data between different Earth shapes by hand might be easy from a purely technical/mathematical perspective. But, there might be introduced some errors if ones has no idea about different reference systems and Earth shapes ... .  
> **username_2**: @a_donda The `.xyz` format for GMT doesn't need cartesian coordinates as requested in [Converting from longitude\latitude to Cartesian coordinates](https://stackoverflow.com/questions/1185408/converting-from-longitude-latitude-to-cartesian-coordinates#1185413). 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`.  
> **username_2**: @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  

---

## 3 answers

### Answer by username_2 on 2020-04-01. Score: 3

**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](ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/grd/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](https://i.sstatic.net/L894w.png)](https://i.sstatic.net/L894w.png)


---

### Answer by username_3 on 2020-04-04. Score: 1

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!


---

### Answer by username_0 on 2020-04-05. Score: 0

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

> **Comments:**
> **username_2**: Please provide some example code on how the conversion works. This might help other users having the same problem. Thanks.  

---

