READHGT: Import/download NASA SRTM data files (.HGT)

Imports or download SRTM worldwide digital elevation model data files.
7.9K Downloads
Updated 18 Aug 2021

View License

This function imports .HGT "height" binary data files from NASA SRTM global digital elevation model of Earth land, corresponding to 1x1 degree tiles of 3-arc seconds resolution (SRTM3, around 90 m) and 1-arc second (SRTM1, around 30 m), and returns coordinates vectors latitude and longitude, and a matrix of elevation values.
The function includes also an automatic download of data from the USGS SRTM webserver, so indicating latitude and longitude is sufficient to get the data and instant map plot anywhere in the World.
Few examples:
readhgt(46:47,-123:-122)
plots a map of Seattle and surrounding volcanoes,
X = readhgt(48,2,'plot');
plots a map of Paris (France) and returns downloaded SRTM data in structure X.
Type "doc readhgt" for syntax, options, other examples and use.

Cite As

François Beauducel (2024). READHGT: Import/download NASA SRTM data files (.HGT) (https://www.mathworks.com/matlabcentral/fileexchange/36379-readhgt-import-download-nasa-srtm-data-files-hgt), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
3.0.1.1

3.0.1.0 with codes included (!)

3.0.1.0

change USGS web site to mirror for SRTM3 tiles

3.0.0.0

new option 'login' to specify user and password at NASA/EarthDATA center (free registration needed) in order to download SRTM1 tiles (in addition to 'srtm1' option).

2.9.0.0

- replaces unzip with webread function, a workaround to automatic download failure

2.8.0.0

- 'decim' option applies also to output grid(s).

2.7.0.0

adds new option 'wget' to workaround an issue with older releases (< 2014b), when downloading tiles automatically. This option works only for Linux and MacOSX. See documentation for further explanation.

2.6.0.0

MAJOR UPDATE: changed URL protocol to access USGS SRTM3 files. This is to avoid "offshore tiles" message when downloading new files. An alternative is to always use the URL option:
readhgt(...,'url','https://dds.cr.usgs.gov/srtm/version2_1')

2.5.0.0

updates URL for world-wide SRTM1 tiles. Still unofficial...

2.4.0.0

- fix issue when merging SRTM1 tiles

2.3.0.0

- fix a problem when SRTM1 tiles are not found.

2.2.0.0

- fix in AREA syntax

2.1.0.0

- new options 'outdir' and 'url' (replacing former syntax)
- improves documentation

2.0.0.0

- new syntax readhgt(AREA)
- now can download SRTM1 30-m resolution tiles worldwide with option 'srtm1'

1.13.0.0

- 'merge' option is now default. Use new 'tiles' option to plot/download individual tiles when lat/lon are vectors
- LON argument is now automatically normalized to -180/+179°
- dem.m companion function update

1.12.0.0

improve backward compatibility (strjoin)

1.11.0.0

corrects an issue with tiles above latitude 54N (thanks to Greg).

1.10.0.0

- bug correction in case of READHGT(FILENAME)
- rewriting of help
- minor corrections

1.9.0.0

- new 'interp' option that fills the novalue gaps
- new 'crop' option to select rectangle part of tile(s)
- updated DEM companion function

1.8.0.0

minor update

1.7.0.0

- improves coding
- upgrades companion dem.m function

1.6.0.0

Bug correction when "dem.m" function is not detected.

1.5.0.0

- minor modifications
- now uses DEM function (included in ZIP file) for basemap axis and legends

1.3.0.0

- adds possibility to download multiple tiles with merge option
- improved graphic output

1.2.0.0

- adjust aspect ratio with latitude
- add minimal basemap axis ticks

1.1.0.0

- now reads also SRTM1 USA territory (1 arc-second resolution) data files.
- minor bug corrections.

1.0.0.0