Skip to content

Instantly share code, notes, and snippets.

@K-Francis-H
Last active February 16, 2017 03:14
Show Gist options
  • Select an option

  • Save K-Francis-H/3bf8d50a134cbb1ed7f3d6baf427db0e to your computer and use it in GitHub Desktop.

Select an option

Save K-Francis-H/3bf8d50a134cbb1ed7f3d6baf427db0e to your computer and use it in GitHub Desktop.
GNU Octave script to load SRTM1 and SRTM3 data and print a grayscale image of the data
#!/usr/bin/octave -qf
%usage: ./display_heightmap.m FILENAME FILETYPE
args = argv();
file_name = args{1};
file_type = args{2}; %should be one of {"srtm1", "srtm3"}%
if(file_type == "srtm1")
size = 3601;
else
size = 1201;
endif
fid = fopen(file_name, "r", "ieee-be");
data = fread(fid, [size, size], "int16"); %3601 is SRTM1, 1201 is SRTM3%
fclose(fid);
data = data/max(max(data));
data = data';
imshow(data);
pause;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment