Create heat map based on location and temperature

19 ビュー (過去 30 日間)
Dion Theunissen
Dion Theunissen 2021 年 7 月 23 日
コメント済み: KSSV 2021 年 7 月 23 日
Hi,
I want to make a raster field, with latitude on the x axis and longitude on the y axis.
From this i want to plot points in this field and make a colour based on the temperature. I have a matrix which contains the latitude coordinate, longitude coordinate and temperature. I want to create something like this:
At the moment I have the folowing, but now I am not able to plot given colours.
%%
ax = worldmap('Europe')
load coastlines
plotm(coastlat,coastlon)
cities = shaperead('worldcities', 'UseGeoCoords', true);
geoshow(ax,cities, 'Marker', '.', 'Color', 'red')
Lon = [cities.Lon].';
Lat = [cities.Lat].';
RTD = Lon < 30;
Lon(RTD) = [];
Lat(RTD) = [];
RTD = Lon > 75;
Lon(RTD) = [];
Lat(RTD) = [];
RTD = Lat < -15;
Lat(RTD) = [];
Lon(RTD) = [];
RTD = Lat > 45;
Lat(RTD) = [];
Lon(RTD) = [];
key = 'MyKey';
Map = []
for i = 1:length(Lon)
Lon1 = num2str(Lon(i));
lon1 = Lon(i);
Lat1 = num2str(Lat(i));
lat1 = Lat(i);
options = weboptions('ContentType','json');
url = ['https://api.openweathermap.org/data/2.5/weather?lat=',Lat1,'&lon=',Lon1,'&units=metric&appid=',key];
Current_Data = webread(url, options);
temp = [Current_Data.main.temp].';
Map1 = [lon1,lat1, temp];
Map = [Map;Map1];
end
figure
Map(:,3)=Map(:,3)./max(Map(:,3));
axesm sinusoid;
for n=1:length(Map)
plotm(Map(n,2),Map(n,1),'o','MarkerFaceColor',[0.5 0.5 Map(n,3)],'MarkerSize',5);
end
  1 件のコメント
KSSV
KSSV 2021 年 7 月 23 日
You can get the coordinates of each region , assign color and use patch, fill.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by