首先知根知底,matlab他这个自带的工具包是什么样子的
里面有一些函数
比如mapshow;geoshow
案例1
a = worldmap('China');
% 其中的China是描绘中国地图,要是换做其他地图,就可以换成
% 在这里china是中心点
%‘World’,或者'North Pole', 'South Pole', 'Pacific'。
% 只是将中国地图区域画出来;并没有显示国界线
% landareas = shaperead('landareas.shp','UseGeoCoords', true);
% geoshow (landareas, 'FaceColor', [1 1 .5]);
% 读取大陆
load coast
plotm(lat, long)
%画出大陆的海岸线
setm(gca,'MLineLocation',5)%设置经度间隔为5
setm(gca,'PLineLocation',10)%设置纬度间隔为10
%设置经纬度的间隔
setm(gca,'MLabelLocation',5)%设置经度标签为每隔5度
setm(gca,'PLabelLocation',10)%设置纬度标签为每隔10度
%设置经纬度标签的间隔
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(a, land, 'FaceColor', [0.5 0.7 0.5])
%给大陆加上颜色
案例2
这里需要用到省界的包
省界国界的matlab可读包
path(path,'F:\new_matlab_Tool\h_china_map\china_map1\maps')
area=shaperead('bou2_4p.shp');%读取省界shp文件的内容
%bou2_4p.shp是省的边界线
bx=[area(:).X];%提取经度信息
by=[area(:).Y];%提取纬度信息
Proj='mercator'; %投影方式
figure;
set(gcf,'unit','normalized','position',[0.2,0.2,0.6,0.4]);
%设置图像大小
latmin=10; latmax=60; lonmin=70; lonmax=140;
%设置显示范围
ax1=axesm(Proj,'MapLatLimit',[latmin latmax], ...
'MapLonLimit', [lonmin lonmax],'Frame','on');
%显示投影方式;与坐标轴范围
gridm on;mlabel on; plabel on;axis off;
%网格;mlabel横;plabel纵;axis关
setm(ax1,'MLineLocation',10,'PLineLocation',10, ...
'MLabelLocation',20,'PLabelLocation',10);
%setm(gca,'MLineLocation',10)为设置经度间隔
%setm(gca,'PLineLocation',10)为设置纬度间隔
%setm(gca,'MLabelLocation',20)为设置经度标签每隔几度
%setm(gca,'PLabelLocation',10)为设置纬度标签每隔几度
setm(ax1,'FontSize',10,'MLabelParallel','south');
%字体大小;横坐标
geoshow(by,bx,'Color','black','LineWidth',1.4);
axes('Position',[0.65 0.2 0.12 0.25]);
% 每个人电脑不同,可以调整position
%设置小图
ax2=axesm(Proj,'MapLatLimit',[2 26], ...
'MapLonLimit', [106 122],'Frame','on');
gridm off;mlabel off; plabel off;axis off;
geoshow(by,bx,'Color','black','LineWidth',1.4);
案例3
这里需要用到省界与国界
省界国界的matlab可读包
figure
path(path,'F:\new_matlab_Tool\h_china_map\china_map1\maps')
%==============
fnshp_L='bou2_4l.shp';
fnshp_P='bou2_4p.shp';
readL=shaperead(fnshp_L);
readP=shaperead(fnshp_P);
%==============
% a = worldmap('China');%描绘出中国地图的轮廓,其中的China是描绘中国地图;
worldmap([15,55],[70,140]); %指定经纬度范围
geoshow(fnshp_L,'Color','k');
%=============绘制海岸线
load coast
plotm(lat, long,'Color','k') ;% plotm(lat, long) %海岸线默认颜色为蓝色
hold on;
%==============
%设置经纬度的间隔
setm(gca,'MLineLocation',5)%设置经度间隔为5
setm(gca,'PLineLocation',10)%设置纬度间隔为10
%设置经纬度标签的间隔
setm(gca,'MLabelLocation',10)%设置经度标签为每隔5度
setm(gca,'PLabelLocation',5)%设置纬度标签为每隔10度
title('China','FontSize',14,'FontWeight','Bold')
如果想用m_map画地图可参考下面链接
matlab m_map所有学习资源汇总