Code covered by the BSD License

5.0

5.0 | 5 ratings Rate this file 86 Downloads (last 30 days) File Size: 63.7 KB File ID: #36379

25 Apr 2012 (Updated )

File Information
Description

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) for USA territory, 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.

Examples:

plots a map of Seattle and surrounding volcanoes,

plots a map of Paris (France) and returns downloaded SRTM data in structure X.

Type "doc readhgt" for syntax, examples and use.

Required Products MATLAB
MATLAB release MATLAB 6.5 (R13)
29 Nov 2013
30 Sep 2013

Very useful tool, excellent documentation!

10 Apr 2013

Regarding my previous comment, I just now noticed you recently added the 'crop' argument update which is exactly what I needed. You are way ahead of me... Amazing what a little bit of reading can do :) Thanks.

01 Aug 2012

A user asked me how to extract an elevation profile from SRTM data... here is a little example (Mount Etna, Sicily):

[x,y] = ginput(2)

then left-click on 2 different points: you will get 2 coordinates in x and y vectors. Then interpolate to create a profile vector:

xi = linspace(x(1),x(2));
yi = linspace(y(1),y(2));
zi = interp2(X.lon,X.lat,double(X.z),xi,yi);

note you need to use the DOUBLE command since SRTM elevation data are int16 class. Plot the profile on the DEM:

hold on,plot(xi,yi,'r'),hold off

Since x and y are longitudes and latitudes, the linear profile is an equirectangular approximation (rhumb line or loxodrome) of the great circle... To compute distance along this path:

di = sqrt(((xi-x(1)).*cosd(yi)).^2 + (yi-y(1)).^2)*6370*pi/180;

where cosd(yi) reduces longitude distance versus latitude, and last factor is latitude degree length in km. Then plot the profile:

figure
plot(di,zi)

that's all. If you know the profile coordinates, you don't need to use GINPUT and you directly define xi and yi with LINSPACE.

28 May 2012
15 May 2012

Thanks Warwick for your kind feedback. I'll add a 2x2 tile option, in few days.
François.

14 May 2012

thank you. this is terrific, and surprisingly fast. A suggestion for a small increase in quick and easy usability would be an example of a 2by2 tile.

26 Apr 2012

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

14 May 2012

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

18 May 2012

- improved graphic output

29 May 2012

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

26 Sep 2012

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

03 Jan 2013

- improves coding

04 Jan 2013

minor update

21 Jan 2013

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

23 Sep 2013

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