Create heat map based on location and temperature

4 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by