How to create a 2d colormap having temperature reading at specific Longitudes and Latitudes

8 views (last 30 days)
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.

Answers (2)

Youssef  Khmou
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
Cristina
Cristina on 20 Apr 2014
Thank you so much for responding, i tried this but it does not plot on the map plot. And in this case where do I input the temperature so that it creates randn based on the value that was recorded. Im new to MATLAB. I appreciate your help.
Youssef  Khmou
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?

Sign in to comment.


Walter Roberson
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 .
  2 Comments
Cristina
Cristina on 24 Apr 2014
In this case should i make x a matrix of 2 rows (lat, lon)? I was reading examples and the way the geoid for example is loaded is a 180x360 matrix (1 degree per cell) so I want to make a matrix at about .1 per cell since its a small location from about 12-22N latitude and 65-77W longitude. I have 79 values for temperature at 79 locations. I want to use those temperatures with their corresponding coordinates to interpolate so that i can fill that matrix and then use it the way the geoid is used. This may be a strange way to go about it but because i am not familiar with MATLAb this seems to be the only way that makes sense to me.
Cristina
Cristina on 24 Apr 2014
I am unclear because V (in my case temperature) is not a function of X,Y (lat, long) its just a reading i have. Also i am unclear how to defien xq yq to get vq.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!