function m_grid(varargin);
% M_GRID make a grid on a map.
% M_GRID('parameter','value',...) with any number (or no)
% optional parameters is used to draw a lat/long grid for a
% previously initialized map projection.
%
% The optional parameters allow the user
% to control the look of the grid. These parameters are listed
% by M_GRID('get'), with defualt parameters in M_GRID('set');
%
% see also M_PROJ
% Rich Pawlowicz (rich@ocgy.ubc.ca) 2/Apr/1997
%
% This software is provided "as is" without warranty of any kind. But
% it's mine, so you can't sell it.
%
% 19/6/97 - set visibility of titles and so forth to 'on' (they
% default to 'off' when axes visibility is turned off)
% 2/11/97 - for M5.1, the old way of making the patch at the bottom (i.e.
% by rearranging the axes children) instead causes matlab to lose
% track of titles. Try a different fix.
% 11/01/98 - Added way of making longitude lines cut off to prevent crowding near poles (you have
% to specify a vector for allowabale latitudes for this to work).
% 16/02/98 - Made a little fudge to allow the user to fully specify grid location
% without getting the edge points. It doesn't quite work if only *one* edge
% point is desired....but I hope it will be OK that way.
% 19/02/98 - PC-users complain about layers getting out of order! Their fault for using
% such an awful OS...however (with help from Eric Firing) I think I have
% a fix.
% 7/04/98 - Another fix to grid locations to not automatically add edge points
% (as requested by EF)
% 7/05/98 - Added 'fancy' outline box.
% 14/11/98 - Changed tag names from m_* to m_grid_*.
% 11/07/99 - Apparently fontname changing didn't work (thanks to Dave McCollum)
% 28/04/04 - Changed m_grid_color code so it works right under unix; old
% way retained for windows (ugh).
% 16/10/05 - Kirk Ireson discovered that the way to fix those annoying 'cut-throughs'
% in fancy_box was to add a 'large' zdata...so I've adapted his fix in
% fancybox and fancybox2.
% 21/11/06 - added 'backcolor'
% 16/4/07 - sorted ticklabels when user-specified (prevents an odd problem near in
% azimuthal projections).
% 4/DEc/11 - isstr to ischar
% 7/Dec/11 - Octave 3.2.3 compatibility
% Note that much of the work in generating line data
% is done by calls to the individual projections -
% most of M_GRID is concerned with the mechanics of plotting
% These structures are initialized by m_proj()
global MAP_PROJECTION MAP_VAR_LIST
% Have to have initialized a map first
if isempty(MAP_PROJECTION),
disp('No Map Projection initialized - call M_PROJ first!');
return;
end;
% Recognize Octave
a=ver;
if strcmp(a(1).Name,'Octave'),
IsOctave=logical(1);
else
IsOctave=logical(0);
end;
% Otherwise we are drawing a grid!
% Set current projection to geographic
Currentmap=m_coord('set');
m_coord(MAP_PROJECTION.coordsystem.name);
% Default parameters for grid
xtick=6;
ytick=6;
xlabels=NaN;
ylabels=NaN;
gcolor='k';
gbackcolor='w'; %%get(gcf,'color');
glinestyle=':';
glinewidth=get(gca,'linewidth');
gbox='on';
gfontsize=get(gca,'fontsize');
gfontname=get(gca,'fontname');
gxaxisloc=get(gca,'xaxislocation');
gyaxisloc=get(gca,'yaxislocation');
gtickdir=get(gca,'tickdir');
gticklen=get(gca,'ticklength'); gticklen=gticklen(1);
gxticklabeldir='middle';
gyticklabeldir='end';
dpatch=5; % interpolation factor for fancy grids
% Parse parameter list for options. I really should do some
% error checking here, but...
k=1;
while k<=length(varargin),
switch lower(varargin{k}(1:3)),
case 'box',
gbox=varargin{k+1};
case 'xti',
if length(varargin{k})==5,
xtick=sort(varargin{k+1}); % Added 'sort' here for people who put things in
else % a random order near poles
xlabels=varargin{k+1};
end;
case 'yti',
if length(varargin{k})==5,
ytick=sort(varargin{k+1});
else
ylabels=varargin{k+1};
end;
case 'xla',
gxticklabeldir=varargin{k+1};
case 'yla',
gyticklabeldir=varargin{k+1};
case 'col',
gcolor=varargin{k+1};
case 'bac',
gbackcolor=varargin{k+1};
case 'lin',
switch lower(varargin{k}(1:5)),
case 'linew',
glinewidth=varargin{k+1};
case 'lines',
glinestyle=varargin{k+1};
end;
case 'fon',
switch lower(varargin{k}(1:5)),
case 'fonts',
gfontsize=varargin{k+1};
case 'fontn',
gfontname=varargin{k+1};
end;
case 'xax',
gxaxisloc=varargin{k+1};
case 'yax',
gyaxisloc=varargin{k+1};
case 'tic',
switch lower(varargin{k}(1:5)),
case 'tickl',
gticklen=varargin{k+1};
case 'tickd',
gtickdir=varargin{k+1};
end;
case {'get','usa'},
disp(' ''box'',( ''on'' | ''fancy'' | ''off'' )');
disp(' ''xtick'',( num | [value1 value2 ...])');
disp(' ''ytick'',( num | [value1 value2 ...])');
disp(' ''xticklabels'',[label1;label2 ...]');
disp(' ''yticklabels'',[label1;label2 ...]');
disp(' ''xlabeldir'', ( ''middle'' | ''end'' )');
disp(' ''ylabeldir'', ( ''end'' | ''middle'' )');
disp(' ''ticklength'',value');
disp(' ''tickdir'',( ''in'' | ''out'' )');
disp(' ''color'',colorspec');
disp(' ''backcolor'',colorspec');
disp(' ''linewidth'', value');
disp(' ''linestyle'', ( linespec | ''none'' )');
disp(' ''fontsize'',value');
disp(' ''fontname'',name');
disp(' ''XaxisLocation'',( ''bottom'' | ''middle'' | ''top'' ) ');
disp(' ''YaxisLocation'',( ''left'' | ''middle'' | ''right'' ) ');
return;
case 'set',
disp([' box = ' gbox]);
disp([' xtick = ' num2str(xtick)]);
disp([' ytick = ' num2str(ytick)]);
disp([' ticklength = ' num2str(gticklen)]);
disp([' tickdir = ' gtickdir]);
disp([' xlabeldir = ' gxticklabeldir]);
disp([' ylabeldir = ' gyticklabeldir]);
disp([' color = ' gcolor]);
disp([' linewidth = ' num2str(glinewidth)]);
disp([' linestyle = ' glinestyle]);
disp([' fontsize = ' num2str(gfontsize)]);
disp([' fontname = ' gfontname]);
disp([' XaxisLocation = ' gxaxisloc]);
disp([' YaxisLocation = ' gyaxisloc]);
return;
end;
k=k+2;
end;
if IsOctave & strcmp(gbox,'fancy'),
warning('No fancy box outlines with Octave');
gbox='on';
end;
if strcmp(gbox,'fancy'),
if strcmp(MAP_VAR_LIST.rectbox,'on') | strcmp(MAP_VAR_LIST.rectbox,'circle'),
gbox='on';
warning([' No fancy outline with ''rectbox'' set to ''' MAP_VAR_LIST.rectbox '''']);
end;
end;
% Draw the plot box
[X,Y]=feval(MAP_PROJECTION.routine,'box');
if strcmp(gbox,'on');
line(X(:),Y(:),'linestyle','-','linewidth',glinewidth,'color',gcolor,'tag','m_grid_box','clipping','off');
end;
% Axes background - to defeat the inverthardcopy, I need a non-white border (the edgecolor),
% but sneakily I can set it's width to (effectively) 0 so it doesn't actually show!
if ~IsOctave,
% This is a very problematic part of the code. It turns out the the interaction between
% PATCH objects and CONTOURF objects does not work correctly in the Painters renderer -
% this is true in all versions up to 7.7 at least. Patches with large negative Z just
% don't get drawn under contourgroup patches.
%
% There are several possible workarounds:
%
% 1) Make sure you use the 'v6' option in contourf calls (see m_contourf.m to see
% how I have tried to do that for some versions of matlab)
% - problem: the 'v6' option is going away soon, also you may want the
%
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab的m_map工具箱 对习惯使用matlab的人来说,m_map是一个很好的绘制地图的免费工具箱。可以选择的投影种类近20种,包括常用的Lambert、Mercator、UTM等。可以测量距离( m_lldist, m_xydist ),绘制等值线(m_contour),等值线填充图(m_contourf),矢量图(m_quiver),栅格图(m_pcolor)等,并与相应的matlab函数语法类似,很容易使用。 m_map通过m_coast提供1/4 degree分辨率的全球海岸线,通过下载GSHHS可以得到更高分辨率的海岸线数据。 除海岸线外,还可以利用已有的GIS行政边界资料,在地图上添加行政边界底图。具体作法为:下载.shp格式的行政边界文件( 国家基础地理信息系统的下载服务),将下载的.shp文件通过mapinfo转换成.dxf文件,利用已编译好的fortran程序,读取经纬度信息,输出.dat文件。导入matlab空间,可以直接m_plot,也可以调用m_plotbndry()。 通过以上方法可以实现.shp在matlab绘图中的应用。
资源推荐
资源详情
资源评论
收起资源包目录
m_map1.4.zip (97个子文件)
m_map
m_vec.m 14KB
m_usercoast.m 852B
m_etopo2.m 5KB
m_legend.m 3KB
m_contourf.m 2KB
m_mag2geo.m 1KB
map.html 31KB
m_plotbndry.m 4KB
m_gshhs_l.m 1KB
m_coord.m 2KB
m_demo.m 8KB
private
track1.gif 7KB
extbase.gif 13KB
mu_util.m 12KB
exgshhs.gif 13KB
thumb_exmiller.gif 854B
exsinus.gif 15KB
mapug.html 74KB
ex_modis.gif 45KB
thumb_exquiv.gif 923B
m_coasts.mat 136KB
mp_cyl.m 4KB
mp_utm.m 10KB
thumb_exlamber.gif 1KB
mlogo.gif 4KB
exobl2.gif 5KB
exmiller.gif 8KB
mc_coords.m 4KB
mp_tmerc.m 9KB
mp_azim.m 10KB
thumb_track1.gif 3KB
thumb_extblueocean.gif 3KB
mp_conic.m 11KB
ex_ssmi.gif 42KB
mp_omerc.m 6KB
ex_sst.gif 43KB
thumb_ex_terra.gif 11KB
thumb_rring.gif 4KB
thumb_extbase.gif 5KB
clabel.m 16KB
thumb_extspeckle.gif 2KB
exster.gif 11KB
mu_coast.m 23KB
exquiv.gif 9KB
ex_terra.gif 147KB
rring.gif 10KB
usermap.gif 9KB
thumb_exgshhs.gif 5KB
thumb_exster.gif 4KB
mc_ellips.m 587B
exlamber.gif 10KB
thumb_exsinus.gif 5KB
thumb_mlogo.gif 3KB
thumb_ex_ssmi.gif 5KB
exvec.gif 12KB
thumb_ex_modis.gif 6KB
extblueocean.gif 7KB
thumb_exvec.gif 3KB
thumb_ex_sst.gif 5KB
mp_conic.m.OLD 8KB
thumb_exobl2.gif 530B
new.gif 118B
extspeckle.gif 10KB
m_gshhs_f.m 1KB
m_text.m 1KB
m_fdist.m 5KB
m_pcolor.m 2KB
m_line.m 1KB
m_xydist.m 884B
m_ll2xy.m 2KB
m_grid.m 25KB
m_elev.m 3KB
m_tba2b.m 1KB
m_idist.m 10KB
m_contour.m 1KB
Contents.m 5KB
m_ruler.m 8KB
m_geo2mag.m 1KB
m_plot.m 754B
m_gshhs_c.m 1KB
m_shaperead.m 9KB
m_hatch.m 8KB
m_track.m 7KB
m_range_ring.m 3KB
m_gshhs_h.m 1KB
m_scale.m 3KB
m_coast.m 926B
m_lldist.m 2KB
m_geodesic.m 2KB
m_quiver.m 3KB
m_gshhs_i.m 1KB
m_patch.m 1KB
m_proj.m 5KB
m_tbase.m 5KB
m_ungrid.m 863B
m_gshhs.m 3KB
m_xy2ll.m 941B
共 97 条
- 1
资源评论
- yjdragon102015-03-10使用这个工具来计算UTM和测量距离还不错,推荐.
- gaofeigou69592013-01-07下了。。不知道怎么用啊??
- cjjdream2015-09-09不错的地图工具箱,我就是用这个工具箱完成了地图开发,挺齐全的
whucv
- 粉丝: 507
- 资源: 139
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功