how to plot 3d surface maps? interpolation?
29 views (last 30 days)
Show older comments

Hi All,
i am struggeling to have a correct interpolation (IDW) for 3d surface maps for the spatial analysis of the parameters collected by CTD to plot temperature (as an example). There is something wrong!
any help is very much appreciated
the steps are below:
1- list of mat fiels each of this mat files contains T table inside (screenshot shows).
2- download the mat fiels
3- grid the data from mulitple CTD locations
4- Surface maps with the coastlines
dataDir = '/';
files = dir(fullfile(dataDir, '*.mat'));
T_all = table();
for i = 1:length(files)
fname = fullfile(dataDir, files(i).name);
S = load(fname);
if isfield(S,'T')
Ti = S.T;
Ti.SourceFile = repmat(string(files(i).name), height(Ti), 1);
Tall = [Tall; Ti];
else
warning('%s does not contain table T', files(i).name)
end
end
depth_target = 2.0; % meters
tol = 0.5; % ±0.5 m
Tz = Tall(abs(Tall.Depth_m - depth_target) <= tol, :);
[G, station, date] = findgroups(Tz.Station, Tz.Date);
Tmap = table();
Tmap.Station = station;
Tmap.Date = date;
Tmap.Lat = splitapply(@mean, Tz.Lat, G);
Tmap.Lon = splitapply(@mean, Tz.Lon, G);
Tmap.Temp = splitapply(@mean, Tz.Temp_C, G);
min_map_lon = 35.2;
max_map_lon = 37.2;
min_map_lat = 25.1;
max_map_lat = 27.6;
[LonGrid, LatGrid] = meshgrid( ...
linspace(min_map_lon, max_map_lon, 250), ...
linspace(min_map_lat, max_map_lat, 250));
TempGrid = griddata( ...
Tmap.Lon, Tmap.Lat, Tmap.Temp, ...
LonGrid, LatGrid, 'v4'); % IDW
load RS_bathy_gebgo % longitude, latitude, bathy
orient portrait
figure
hold on
m_proj('mercator', ...
'lon',[min_map_lon max_map_lon], ...
'lat',[min_map_lat max_map_lat]);
m_pcolor(longitude, latitude, bathy);
shading interp
colormap(flipud(gray))
caxis([-1200 0])
h = m_pcolor(LonGrid, LatGrid, TempGrid);
set(h,'FaceAlpha',0.85) % transparency so bathy shows
shading interp
colormap(turbo)
m_usercoast('red_sea_f','patch',[0.8 0.8 0.8])
m_grid('contour','on','tickdir','out', ...
'box','fancy','fontsize',10, ...
'linewidth',1,'linestyle','--');
colorbar
ylabel('Latitude','fontsize',16,'fontweight','bold');
xlabel('Longitude','fontsize',16,'fontweight','bold');
2 Comments
Mathieu NOE
about 3 hours ago
hello
could you please share a couple of mat files (size < 5Mb if possible)
Star Strider
about 1 hour ago
You appear to be using something other than the Mapping Toolbox functions for this. It seems to have a number of interpolation and surface plotting functions specific to geographic coordinates.
You need to supply the functions you are calling, a link to the third-party toolbox you are using, as well as supplying the data (if possible) to get help with this.
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!