Geoscience Reference
In-Depth Information
fid = fopen('S01E036.hgt','r');
SRTM = fread(fid,[1201,inf],'int16','b');
fclose(fid);
h is script opens the i le s01e036.hgt for read only access using fopen and
dei nes the i le identii er fid , which is then used to read the binaries from
the i le (using fread ) and to write them into the matrix SRTM . Function fclose
closes the i le dei ned by fid . h e matrix i rst needs to be transposed and
l ipped vertically.
SRTM = SRTM'; SRTM = flipud(SRTM);
h e -32768 l ag for data voids can be replaced by NaN , which is the MATLAB
representation for Not-a-Number.
SRTM(find(SRTM == -32768)) = NaN;
h e SRTM data contain numerous gaps that might cause spurious ef ects
during statistical analysis or when displaying the digital elevation model
in a graph. A popular way to eliminate gaps in digital elevation models is
by i lling gaps with the arithmetic means of adjacent elements. We use the
function nanmean since it treats NaN s as missing values and returns the mean
of the remaining elements that are not NaN s. h e following double for loop
averages SRTM(i-1:i+1,j-1:j+1) arrays, i.e., averages over three-by-three
element wide areas of the digital elevation model.
for i = 2 : 1200
for j = 2 : 1200
if isnan(SRTM(i,j)) == 1
SRTM(i,j) = nanmean(nanmean(SRTM(i-1:i+1,j-1:j+1)));
end
end
end
clear i j
If there are still NaN s in the data set (as in our example) causing errors when
importing the data set into a Virtual Reality Modeling Language (VRML)
client, the double for loop can be run a second time. Finally, we check
whether the data are now correctly stored in the workspace by printing the
minimum and maximum elevations of the area.
max(SRTM(:))
ans =
3992
min(SRTM(:))
Search WWH ::




Custom Search