Plot Heat map using latitude longitude and other vector

1 visualización (últimos 30 días)
Paj
Paj el 29 de En. de 2018
Comentada: Paj el 29 de En. de 2018
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

Respuestas (1)

KSSV
KSSV el 29 de En. de 2018
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 comentario
Paj
Paj el 29 de En. de 2018
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

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by