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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/693254/image.png)
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!