Plot Heat map using latitude longitude and other vector
2 次查看(过去 30 天)
显示 更早的评论
Hi all, I want to plot a heatmap on a worldmap based on the latitude, longitude and power output of powerplants around the world, i.e, colour varies based on amount of power generated. I'm having issues using contourfm. Any suggestions on how to properly use contourfm or any other methods for heatmapping is much appreciated. I have the following code (attached with raw data files as well):
clear all;clc;
Location = uigetdir;
D = dir([Location, '\*.xlsx']);
filenames = {D(:).name}.';
data = cell(length(D),1);
worldmap world
load coastlines
[latcells, loncells] = polysplit(coastlat, coastlon);
numel(latcells);
axesmui;
antarcreg=coastlat < -63;
plotm(coastlat(~antarcreg),coastlon(~antarcreg))
whos;
for ii = length(D):-1:1
fullname = [Location filesep D(ii).name];
[~,txt,~] = xlsread(fullname,'I:I');
[num,~,~] = xlsread(fullname,'H:H');
num(isnan(num))=1;
if ismember(txt(1,:), 'point');
txt(1,:)='';
end
conv=char(txt);
conv=str2num(conv);
latitude=conv(:,1);
longitude=conv(:,2);
checklat=conv(:,1);
if length(checklat)==length(num);
x=linspace(min(latitude),max(latitude));
y=linspace(min(longitude),max(longitude));
[X,Y]=meshgrid(x,y);
F=scatteredInterpolant(latitude,longitude,num);
contourfm(latitude,longitude,num,'Linecolor','none');
end
end
0 个评论
回答(1 个)
KSSV
2018-1-29
Let x,y,z be your longitude, latitude and data vector. You can plot the colormap using:
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
trisurf(tri,x,y,z) ;
shading interp ;
colorbar
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!