MATLAB画地图的工具:worldmap和m_map


分类: Matlab |
Mapping Toolbox是Matlab提供的,一整套包含许多函数跟图形用户界面的工具箱;它可以帮助用户分析几何空间方面的数据;并以地图的形式显示出来!
worldmap命令
help worldmap WORLDMAP 创建世界上给定区域的坐标 WORLDMAP 区域 或 WORLDMAP(区域名) 新建一个空的地图坐标,这个投影模型和限制与此区域相适应 . REGION 可能是一个字符串或则 cell array of strings. Permissible strings 包括大陆, 国家,岛屿,比如 'World', 'North Pole', 'South Pole', and 'Pacific'.
-
>>
worldmap world -
%绘制世界地图坐标或
-
>>
worldmap ('world)
http://img.my.csdn.net/uploads/201209/01/1346507572_7875.jpg
1、示例一:带有海岸线的世界地图
coast.m在目录D:Program
FilesMATLABR2010atoolbox
-
>>
% -
worldmap('World') -
load coast -
plotm(lat, long)
>> help plotm
http://img.my.csdn.net/uploads/201209/01/1346507742_1577.jpg
>> help load
2、实例二:带有陆地、主要湖泊河流和城市和人口密集区的世界地图
-
landareas
-
>>
% Worldmap with land areas, major lakes and rivers, and cities and -
% populated places -
ax = worldmap('World'); -
setm(ax, 'Origin', [0 180 0]) -
land = shaperead('landareas', 'UseGeoCoords', true); -
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5]) -
lakes = shaperead('worldlakes', 'UseGeoCoords', true); -
geoshow(lakes, 'FaceColor', 'blue') -
rivers = shaperead('worldrivers', 'UseGeoCoords', true); -
geoshow(rivers, 'Color', 'blue') -
cities = shaperead('worldcities', 'UseGeoCoords', true); -
geoshow(cities, 'Marker', '.', 'Color', 'red')
陆地的表面颜色
geoshow(cities, 'Marker', '.',
'Color', 'red')
城市用'.'标记
H =
WORLDMAP(...)返回地图投影的句柄
>> help setm
-
SETM(H,'MapAxesPropertyName',PropertyValue,...)
-
SETM(H,
'MapPosition', POSITION)
-
SETM(H,
'Graticule', LAT, LON, ALT)
where H is a valid projected surface
object, uses LAT and LON 相同大小的矩阵specify the 格网点.
-
S
= SHAPEREAD(FILENAME)
返回 N×1 结构数组, S,
Name
Attributes
>> help geoshow
-
>>
help geoshow -
GEOSHOW Display map latitude and longitude data -
-
GEOSHOW(LAT, LON) or -
GEOSHOW(LAT, LON, ..., 'DisplayType', DISPLAYTYPE, ...)
projects and displays the latitude
and longitude vectors, LAT and LON, using
the
*用MATLAB画世界地图并加散点
clear;clc;
worldmap([-55 -30],[-110 -60]);
h1=axesm('MapProjection','eqdcylin','maplatlimit',[-58
-30],'maplonlimit',[-110
-60],'frame','on','parallellabel','on','meridianlabel','on','flinewidth',1,'plabellocation',5,'mlabellocation',10);
setm(h1,'fedgecolor',[.5 .6 .6],
'fontname','Arial','fontsize',7);
grid off;
h=geoshow('landareas.shp');
x=
y=
scatterm(y,x,'filled','k')
加等值线
clear;clc;
A=xlsread('2010作图2','5','N2:P26');
[x,y]=meshgrid(-106.5:-81.5,-46.5:-35.5);
z=abs(griddata(A(:,1),A(:,2),A(:,3),x,y,'v4'));
subplot(2,2,1)%figure(1)
worldmap([-55 -30],[-110 -60]);
h1=axesm('MapProjection','eqdcylin','maplatlimit',[-58
-30],'maplonlimit',[-110
-60],'frame','on','parallellabel','on','meridianlabel','on','flinewidth',1,'plabellocation',5,'mlabellocation',10);
setm(h1,'fedgecolor',[.5 .6 .6],
'fontname','Arial','fontsize',7);
grid off;
h=geoshow('landareas.shp');
scatterm(A(:,2),A(:,1),'filled','k')
[c,h] =contourm(y,x,z,[0.6,0.8,0.9],'k-');
hold
on;[cc,hh]=contourm(y,x,z,[0.1,0.2,0.3,0.4,0.5,0.7],'k-');
clabel(c,h)
title('5月')
1、用matlab画世界地图
[matlab自带的例子]
ax = worldmap('World'); setm(ax, 'Origin', [0 180 0]) land = shaperead('landareas', 'UseGeoCoords', true); geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5]) lakes = shaperead('worldlakes', 'UseGeoCoords', true); geoshow(lakes, 'FaceColor', 'blue') rivers = shaperead('worldrivers', 'UseGeoCoords', true); geoshow(rivers, 'Color', 'blue') cities = shaperead('worldcities', 'UseGeoCoords', true); geoshow(cities, 'Marker', '.', 'Color', 'red')
http://s7/bmiddle/4cf8aad3471811f31c1c6&690
2、matlab的m_map工具箱及添加行政边界底图
from http://blog.163.com/ahualian@126/blog/static/2350491720093238409154/
对习惯使用matlab的人来说,m_map是一个很好的绘制地图的免费工具箱。可以选择的投影种类近20种,包括常用的Lambert、Mercator、UTM等。可以测量距离( m_lldist, m_xydist ),绘制等值线(m_contour),等值线填充图(m_contourf),矢量图(m_quiver),栅格图(m_pcolor)等,并与相应的matlab函数语法类似,很容易使用。
通过以上方法可以实现.shp在matlab绘图中的应用。
3、[原创ZHOU Feng]在matlab中利用worldmap画中国区域图时加上台湾和钓鱼岛
from http://www.sciencenet.cn/m/Print.aspx?id=210235
Matlab是我们常用的一个画图和计算、仿真工具,在我们海洋科研中,经常在画图时需要加上底图(譬如海岸线,国界、省界线等等)。常用的一个工具包是M_map。但这里我要讲的是利用matlab自带的一个画图工具包话底图,这个工具包就是worldmap.
不过老实说,我不太用matlab自带的这个画图包,用M_map比较多一点。试验一下,感觉还可以用用。
画上述图的代码如下:
% 把台湾和大陆合成一个文件保存起来,这样画图用patch就是一种颜色(Zhou Feng, 2008-06-30, SOED,
Hangzhou)。
%
% by ZHOU Feng
% zhoufeng@sio.org.cn
% SOED, 2nd Institute of Oceanography
% 2008-06-30
s1 = worldhi('china');
s2 = worldhi('taiwan');
disp(s1);
% add Taiwan together (ZHOU Feng)zhoufeng@sio.org.cn
s = s1;
s.lat = [s1.lat;NaN; s2.lat];
s.long= [s1.long; NaN;s2.long];
% add the Diaoyu Island (钓鱼岛)
% 钓鱼岛群岛由钓鱼岛、黄尾岛、赤尾岛、南小岛、北小岛、大南小岛、大北小岛和飞濑岛等岛屿组成,总面积约7平方公里。
% 地理位置:东经123°-124°34′北纬25°40′-26°。
%
% ---这里的分辨率只有两块 --
s3 = worldhi('japan');
x = s3.long;
y = s3.lat;
idx = find(x>123.0 & x<124.5);
idy = find(y> 25.5 & y< 26.0);
m = length(idy);
id=[];
for i=1:m
end
%%longd = x(id);
%%latd
%
% find nan
dtmp = find(diff(id)>1);
if isempty(dtmp)
elseif length(dtmp)==1
else
end
longd = x(idnew);
latd
s.lat = [s.lat; NaN; latd];
s.long= [s.long; NaN; longd];
worldmap china
h = displaym(s);
polcmap
OK!!!!!!!!!!!!!!!