Clear Filters
Clear Filters

Plotting temperatures in a changing coordinate system

4 views (last 30 days)
I apologize in advance if what I write is confused, it is difficult to put my problem into words.
I have a temperature map of Svalbard, and a DEM with its own coordinate system in lat and lon (300*300 matrix). This sytem is titled and not aligned at all with the north-south axis. I have a function to convert lat, lon in UTM33 x and align everything.
The issue is the following: I have a matrix of lat and a matrix for lon. Temperatures are not directly related to the lat and lon, just on a matrix the same size and therefore oriented the same way. This way, a temperature cell's row and column will have an associated lat and lon in the other matrix. In order to plot everything, because I have matrices for lat and lon, I have to use pcolor (which I don't really like). I would rather use imagesc but I can't get a lat and lon vector that plots everything the right way.
Now, on top of that I have weather stations' temperatures and coordinates (16 of them). I manage to plot them on top of the temperature plot, but I want to make each of the points filled with a color depending on the difference between the temperature of the station and the temperature of the matrix at the station's equivalent point (red if the difference is big, blue when small). But, in order to do so I have to retreive the station's equivalent point in the temperature matrix, which is still in the original coordinate system !
What I think would solve the problem is to convert the temperature matrix in the UTM33x coordinate system, but I have no idea how to do that since it doesn't have any metadata related to coordinates.
Here is my code and the necessary variables to make it run:
% Load variables
load ('SDEMAROME');
lon = SDEMAROME.lon;
%%% UTM33X conversion
[x,y,utmzone] = deg2utm33_matrix(lat,lon);
%%% Mask conversion (Every pixel other than land is set to NaN to be
%%% transparent)
mask = SDEMAROME.mask;
mask(mask == 0) = NaN;
mask_land = mask;
mask_land(mask_land == 2) = NaN;
mask_ice = mask;
mask_ice(mask_ice == 1) = NaN;
%% Surface Temperature figure
h = figure('Visible', true);
%Background land
ax1 = axes;
pcolor(ax1,x(50:250,50:250),y(50:250,50:250),mask_land(50:250,50:250)) %% Resize a bit the window
cb3 = colorbar('Color','none'); %% Ghost colorbars to have all the masks aligned
shading flat
hold on
axis tight
%Background Ice
ax2 = axes;
imAlpha = ones(size(mask_ice));
imAlpha(isnan(mask_ice)) = 0; %% Make NaNs transparent otherwise it covers the other layers
e1 = pcolor(ax2,x(50:250,50:250),y(50:250,50:250),mask_ice(50:250,50:250));
cb3 = colorbar('Color','none');
shading flat
ax3 = axes;
imAlpha = ones(size(T_surface));
imAlpha(isnan(T_surface)) = 0;
e1 = pcolor(ax3,x(50:250,50:250),y(50:250,50:250),T_surface(50:250,50:250));
shading flat
hold on
set(gca, 'Color', 'none');
axis tight
cb3 = colorbar('Color','white');
caxis([-30 10])
ylabel(cb3,'T [°C]','Color','white');
title('Daily Surface Temperature','Color','white');
set(gcf, 'InvertHardCopy', 'off');
set(gcf,'Color',[0 0 0]); % RGB values [0 0 0] indicates black color
% Plot the meteo stations
scatter(stations.x, stations.y)
I tried to gather by hand the row and column values of the tiles closest to the meteo stations on the tilted original figure. But when plotting on the converted figure the values of the temperature where not linked to their original location anymore.
My questions are:
  • How could I plot everything with imagesc OR have the temperature matrix rotated and corresponding to the UTM33x system ?
  • How to retreive the temperature value of the closest tile to a station's location ?
Pcolor manages to align temperatures and lat/lon but it's a black box, I have no idea how it manages to achieve that.
Thank you in advance !!!!

Answers (0)


Find more on Graphics Object Programming 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!