Create heat map based on location and temperature

조회 수: 17 (최근 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 CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by