# How to create a geographic colormap of the world using lat lon data?

조회 수: 80 (최근 30일)
KUMAR TRIPATHY 2021년 7월 10일
댓글: ANKUR KUMAR 2021년 7월 12일
Hello Everyone!
I am quiet familiar with MATLAB since 3 years. I want to create a geographic colormap from some data (data matrix looks like this, longitude, latitude, data). How can I do that with MATLAB?
I have used some matlab code to do it, however matlab only plots the lat lon data, however it can't plot them in the continuous scale, thus the figure looks bad as compared to GMT/ NCL.
I am attaching the code below .
fig=figure('WindowState','maximized');
lat=data(:,2);lon=data(:,1);
marker_size=100;
geoscatter(lat,lon,marker_size,data(:,end),'*','LineWidth',2);
colormap(jet)
colorbar
caxis([0 10])
This is the figure which I got.
I have tried to plot that with Genereic Mapping Tools (GMT), however I want to create it using MATLAB. I am attaching the GMT created figure for your reference below. The figure is created using Robinson Map Projection.
This is the figure I want to create.
Please someone help me to solve this. Thank you very much.
N.B. -- Please don't suggest GMT+ MATLAB built in setup, beacause I am using a Windows system, where GMT isn't supportable.

댓글을 달려면 로그인하십시오.

### 채택된 답변

ANKUR KUMAR 2021년 7월 11일
You can simply use the contour or contourf or imagesc function to do that.
temp=randi(5,50,40)+273;
lon=[50:100];
lat=[0:40];
imagesc(lon,lat,temp)
hold on
plot(coastlon,coastlat,'r','linewidth',2)
set(gca,'Ydir','normal')
colorbar
colormap(flip(bone(8)))
Let us take satellite data to plot the data on map. I am taking TRMM precipitation data as a sample:
figure
filename='trmm_sample_data.txt'; % Attached
% This is a netcdf file, but I have replaced the file extension from .nc to .txt file
% in order to attach .nc file here in the answers.
imagesc(lon,lat,pcp)
hold on
plot(coastlon,coastlat,'r','linewidth',2)
set(gca,'Ydir','normal')
colorbar
colormap(jet(10))
axis([75 90 15 25])
If you have the shapefile of caostlines, or state bundaries, you can load it using shaperead.
##### 댓글 수: 2없음 표시없음 숨기기
KUMAR TRIPATHY 2021년 7월 12일
Thank you very much, It works fine.
However, I have a little concern here. Can I add a geographic projection here to the data and plot it like this.
ANKUR KUMAR 2021년 7월 12일
Yes, you can add or change projection in the map. Please refer to this doc: https://www.mathworks.com/help/map/summary-and-guide-to-projections.html

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Vector and Raster Map Display에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by