Plot Heat map using latitude longitude and other vector

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 日

0 投票

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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

タグ

質問済み:

Paj
2018 年 1 月 29 日

コメント済み:

Paj
2018 年 1 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by