Making a Map Image from a Matrix

4 ビュー (過去 30 日間)
John Ziggs
John Ziggs 2021 年 3 月 13 日
コメント済み: Chad Greene 2021 年 3 月 14 日
Hi all, I am trying to make a map based off data from a text documents containing daily surface air temperature. I attached 2 txt files as a sample. I am trying to create a map based off this.
This is my code:
inputdirTA = 'C:\Users\john\Desktop\TA2004daily'; %directory of folder containing data
S = dir(fullfile(inputdirTA,'*.txt'));
for k = 1:numel(S)
fnm = fullfile(inputdirTA,S(k).name);
vector = load(fnm);
mtx = reshape(vector,72,144);
if k == 1;
DataTA = [mtx];
else
DataTA = [DataTA mtx];
end
end
figure(1);
rv = [0.4 90 0];
worldmap('world');
geoshow(DataTA, rv, 'displaytype', 'texturemap');
C = load('coast');
plotm(C.lat, C.long, 'k');
title('Map of Surface Air Temperature');
I am getting this map:
But I am trying to get this kind of map:
I understand the concept of having to create 3 planes of the matrix, but I am having troubles understanding the syntax.
Any help or advice is greatly appreciated.
Thanks.

採用された回答

Chad Greene
Chad Greene 2021 年 3 月 13 日
編集済み: Chad Greene 2021 年 3 月 13 日
With the Climate Data Toolbox you could do it like this:
T = flipud(reshape(load('TS20040101.txt'),[72 144])); % loads, reshapes, and orients the data correctly
[lat,lon] = cdtgrid(2.5); % creates a 2.5 degree global grid
pcolor(lon,lat,T) % plots the grid
shading interp
cmocean thermal % sets the colormap
borders('countries','color',rgb('gray'))
xlabel longitude
ylabel latitude
You could even take it one step further and interpolate to a high-resolution grid, then plot with hillshaded topography:
% Create a 0.1 degree grid:
[lati,loni] = cdtgrid(0.1);
% Interpolate the temperature data to the high-res grid:
Ti = interp2(lon,lat,T,loni,lati);
% Get elevation data on the high res grid:
Zi = topo_interp(lati,loni);
% Set ocean elevations to zero:
Zi(Zi<0) = 0;
figure
surf(loni,lati,Zi,Ti)
shading interp
view(2)
axis tight equal
cmocean thermal
shadem(-10) % applies hillshade
  3 件のコメント
Image Analyst
Image Analyst 2021 年 3 月 14 日
Very cool Chad. I voted for it to give Chad additional reputation points. John, you can also vote, to award Chad extra points.
Chad Greene
Chad Greene 2021 年 3 月 14 日
Thanks, Mark! That means a lot coming from you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Geodesy についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by