How to create a 2d colormap having temperature reading at specific Longitudes and Latitudes
8 views (last 30 days)
Show older comments
I have a 3 column matrix, lat,long and temperature. I want to create a color map of the country in which these readings are taken from. I dont have readings at every long/lat only about 79 locations within the country. I need to interpolate somehow so that the readings cover not only that specific spot but an area so that the whole country can be depicted in the colormap. I am able to call for the country using the following
worldmap({'Haiti','Dominican Republic'}) >> load coast >> plotm(lat, long)
that gives me an outline of the islands i am working with. Now i need to use the matrix (with 79 specific sites each defined by lat,lon and temperature) to show the avg temperature for that year.
PLEASE HELP i have been googling for hours, everything i find is people who have the third variable at every location for the area they are working with.
any help would be EXTREMELY appreciated.
0 Comments
Answers (2)
Youssef Khmou
on 20 Apr 2014
Cristina,
Here is an alternative approach, the third column represents the color, but it is not easy to create a color map ( you can create linear scale of colors independently), a color is 3by1 vector , we choose two values randomly and we fix the third as value of Temperature :
% Plotting longitude latitude and temperature on map
%worldmap({'Haiti','Dominican Republic'});
%load coast;
%plotm(lat, long);
hold on;
% Example of the matrix
M(:,1)=floor(100*randn(79,1));
M(:,2)=floor(100*randn(79,1));
M(:,3)=floor(100*rand(79,1));
% the third column is temperature it represents the color, we need to
% normalize it
M(:,3)=M(:,3)./max(M(:,3));
axesm sinusoid;
for n=1:79
plotm(M(n,1),M(n,2),'o','MarkerFaceColor',[0.5 0.5 M(n,3)],'MarkerSize',12);
end
% values 0.5 are arbitrary , you can change them ( RGB).
2 Comments
Youssef Khmou
on 20 Apr 2014
you are welcome, i only used randn to simulate the 79x3 matrix that you have, did you relpace M with your matrix? you can post your matrix as M-file?
Walter Roberson
on 24 Apr 2014
If you have a quite new MATLAB then see ScatteredInterpolant or possibly better for you, GriddedInterpolant. If you have a little older MATLAB see TriScatteredInterp .
See Also
Categories
Find more on Map Display in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!