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

回答(1 个)

KSSV
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
  1 个评论
Paj
Paj 2018-1-29
Hi KSSV,
Thanks for your help. I keep getting this though:
Warning: Duplicate data points have been detected and removed. The Triangulation indices are defined with respect to the unique set of points in delaunayTriangulation.
Does the method u proposed work on the mapping toolbox.
Thx

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by