How to colour contour temperature data over its lat and lon?

8 次查看(过去 30 天)
Hi hope all is well,
I have a set of field measurements of temperuature, and the lat lon and depth of where the observation was made. I am trying to plot these data onto a map with temperature in colour contour, at its lat lon it was taken.
My collection contains a mighty 45,000 ish rows thus elimated a few approaches such as mesh, my variables are : lat , lon , temp . I also used geoshow for background map, thus I believe would also be a limiting factor of code choices.
So far, I have tried to use the contour function but I kept getting an error of Z must be at least 2 by 2 , (however, my Z , temp is a single column array).
Please let me know how to plot my temp contours, thanks in advance

回答(2 个)

KSSV
KSSV 2019-2-4
Let lon,lat,Z be your data
M = 100 ; N = 100 ;
xi = linspace(min(lon),max(lon),M) ;
yi = linspace(min(lat),max(lat),N) ;
[Xi,Yi] = meshgrid(Xi,yi) ;
F = scatteredInterpolant(lon,lat,Z,'nearest','none') ;
Zi = F(Xi,Yi) ;
contourf(Xi,Yi,Zi)
  3 个评论

请先登录,再进行评论。


P3tra_
P3tra_ 2019-2-5
Thanks to @KSSV's kind direction, I have successfully got me contour over me geoshow map. However, they do not agree with each other. I reckon it is the lack of projection on my contours, but I do not know for sure. Code as below (my variables are lat , lon , temp):
%2D 'Contour over map'
M = 100 ; N = 100 ;
loni = linspace(min(lon),max(lon), M )
lati = linspace(min(lat),max(lat), N )
[LONi,LATi] = meshgrid(loni,lati)
plot = scatteredInterpolant(lon,lat,temp,'nearest','nearest')
Zi = F (LONi,LATi)
figure
hold on
worldmap ([60 85],[-130 -45])
title ('filetitle')
geoshow('landareas.shp','FaceColor',[0.7 0.8 0.6])
contourm(LATi,LONi,Zi,'ShowText')
hold off
Thanks in advance

Community Treasure Hunt

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

Start Hunting!

Translated by