How to create a 2d colormap having temperature reading at specific Longitudes and Latitudes
조회 수: 14 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Youssef Khmou
2014년 4월 20일
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
Youssef Khmou
2014년 4월 20일
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
2014년 4월 24일
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 .
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!