MATLAB: How to overlay VMAP0 data on a topographic relief surface using the Mapping Toolbox

altitudemappingMapping Toolboxvmap0

I would like to overlay the graphics objects created by plotting VMAP0 data on top of a topographic map. However, the VMAP0 data does not contain altitude information, only latitude and longitude. I need to determine the altitude values to use for the object in order for them to clear the topographic surface.

Best Answer

To achieve this, you need to use interpolation to determine the altitude values to place the graphics objects created from VMAP0 data to sit on a topographic surface. More specifically, you need to use the latitude, longitude, and altitude data from the topographic grid as the basis to calculate the altitude values for the given latitude and longitude values from the VMAP0 data.
% here, Z is an array of altitude values.
[latsize,lonsize] = size(Z);
latlocs = linspace(latlim(1),latlim(2),latsize);
lonlocs = linspace(lonlim(1),lonlim(2),lonsize);
%VMAPlines is a structure of line information, created from VMAP0 data
for i=1:length(VMAPlines)
str = VMAPlines(i).tag;
if ~isempty(strmatch('Accurate;',str))
% since the segments of data are separated by NaNs,
% you will need to interpolate each segment separately
NaNLocs = find(isnan(VMAPlines(i).long));
for n = 1:length(NaNLocs)-1
% get the segment's latitude and longitude data
tmplat = VMAPlines(i).lat(NaNLocs(n)+1:NaNLocs(n+1)-1);
tmplon = VMAPlines(i).long(NaNLocs(n)+1:NaNLocs(n+1)-1);
% interpolate the altitude
tmpalt = interp2(lonlocs,latlocs,Z,tmplon,tmplat);
% add the segment's altitude info, separated by NaNs
VMAPlines(i).alt = [VMAPlines(i).alt; NaN; tmpalt(:)];
end
% display the line
hTRline(i) = displaym(VMAPlines(i));
end
end
You can use this approach to "drape" vector data other than VMAP0 over terrain by substituting the appropriate data structures for VMAPlines. Note that there may be locations where the vectors become hidden for short distances.