Borrar filtros
Borrar filtros

Create heat map based on location and temperature

9 visualizaciones (últimos 30 días)
Dion Theunissen
Dion Theunissen el 23 de Jul. de 2021
Comentada: KSSV el 23 de Jul. de 2021
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 comentario
KSSV
KSSV el 23 de Jul. de 2021
You can get the coordinates of each region , assign color and use patch, fill.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by