1. 简介

晕渲一词源自绘画,指的是用水墨或颜色渐次浓淡烘染物象,使分出阴阳向背的绘画技法(https://baike.so.com/doc/2078427-2198654.html)。

地理学中晕渲图指的是DEM地表形态表达的一种形式,它通过设置光源的高度角和方位角更形象或者更符合人类视觉的方式展示一个地区的地形。通过晕渲图,可以很好的反映地形地势的变化,有很好的立体感,方便用图者的使用(https://baike.baidu.com/item/%E6%99%95%E6%B8%B2%E5%9B%BE)。

具体可参考维基百科:https://en.wikipedia.org/wiki/Terrain_cartography#Shaded_relief。

m_map作为Matlab下一款不错的地形图绘制工具箱,也带有地形晕渲功能。相关函数有:m_etopo2m_shadedrelief

2. 函数说明

先看一下m_shadedrelief函数说明。

>> help m_shadedreliefm_shadedrelief Shaded relief topography in an imagem_shadedrelief(X,Y,Z) presents a shaded relief topography, as wouldbe seen if a 3D model was artifically lit from the side. Slopesfacing the light are lightened, and slopes facing away from the light are darkened. X and Y are horizontal and vertical coordinateVECTORS, and these should be in the same units as the height Z (e.g., all in meters), otherwise the slope angle calculations will be in error. Usage notes:(1) m_shadedrelief is a replacement for a low-level call to IMAGE displaying a true-colour image so it MUST be preceded by COLORMAP and CAXIS calls.  (2) m_shadedrelief probably is most useful as a backdrop to maps witha rectangular outline box - either a cylindrical projection, or someother projection with M_PROJ(...'rectbox','on'). (3) Finally, the simplest way of not running into problems:- if your elevation data is in LAT/LON coords (i.e. in a matrix whereeach row has points with the same latitude, and each column has pointswith the same longitude), use M_PROJ('equidistant cylindrical',...)- if your elevation data is in UTM coords (meters E/N), i.e. in a matrixwhere each row has the same UTM northing and the each column has thesame UTM easting, useM_PROJ('utm',....)m_shadedrelief(...,'parameter',value) lets you set various properties.These are:'coords' : Coordinates of X/Y/Z: 'geog' for lat/lon, Z meters,  (default)'map'  for X/Y map coordinates, Z meters'Z' if X/Y/Z are all in same units (e.g., meters)'lightangle' : true direction (degrees) of light source (default -45, i.e. from the north-west)'gradient': Shading effects increase with slope angle until slopes reach this value (in degrees), and are held constant for higher slopes (default 10). Reduce for smoother surfaces.'clipval' : Fractional change in shading for slopes>='gradient'.0 means no change, 1 means saturation to white or blackif slope is facing directly towards or away from light source, (default 0.9).'nancol'  : RGB colour of NaN values (default [1 1 1]);'lakecol' : RGB colour of lakes (flat sections) (default NaN)If set to NaN lakes are ignored.IM=m_shadedrelief(...) returns a handle to the image.[SR,X,Y]=m_SHADEDRELIEF(...) does not create an image but only returnsthe  true-color matrix SR of the shaded relief, as well as the X/Yvectors needed to display it.Example:load toposubplot(2,1,1);  % Example without itimagesc(topolonlim,topolatlim,topo);caxis([-5000 5000]);colormap([m_colmap('water',64);m_colmap('gland',64)]);set(gca,'ydir','normal');subplot(2,1,2);  % Example with itcaxis([-5000 5000]);colormap([m_colmap('water',64);m_colmap('gland',64)]);m_shadedrelief(topolonlim,topolatlim,topo,'gradient',5e2,'coord','Z');axis tight

函数基本格式如下:

m_shadedrelief('coords',OPTION)

其中coords表示输入的经纬度和高程坐标,OPTION表示可选项。
可选项主要用到2个:lightanglegradient,分别表示光源方位角和坡度(梯度)阈值。

光源方位角lightangle从地理正北方从0°~360°顺时针旋转,或者逆时针旋转,用负角度表示。比如,m_map的m_shadedrelief函数的光源方位角默认值是-45°,即光源位于正西北方向

理论上,晕渲图应该设置光源的方位角和高度角。但是m_map通过设置地形坡度阈值来间接地展示不同高度角的光源照明。通过对大坡度地形设置阴影效果来突出地形起伏变化。坡度角越大,阴影效果越明显,直到坡度角达到设定值(以度为单位),并且对于较高的坡度保持不变(默认值为10)。

另外,需要说明的是,m_etopo2('shadedrelief')函数和m_shadedrelief在某种程度上等价,但是m_etopo2('shadedrelief')更加简单。

下面我们看一下如何用这两个函数绘制晕渲地形图。

3. 实例说明

3.1 例1

使用m_etopo2('shadedrelief'),默认参数(光源方位角-45°,坡度阈值10)。

figname='shadedrelief1';m_proj('mercator','long',[114 124],'lat',[20 26]);caxis([-5000 0]); % 设置显示高程范围,只显示海洋部分colormap((m_colmap('blues',200)));  % 设置色标为m_map自带的m_colmap('blues')
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_etopo2('shadedrelief');m_gshhs('ic','patch',[.6 .6 .6]); % 设置中等分辨率海岸线填充m_grid('box','fancy','gridlines','no','fontsize',14);  % 轴设置set(gcf,'position',[100 100 800 500]) %图形大小设置
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

3.2 例2

使用m_etopo2('shadedrelief'),光源方位角设置为45°,默认坡度阈值10°。

figname='shadedrelief2';m_proj('mercator','long',[114 124],'lat',[20 26]);caxis([-5000 0]); % 设置显示高程范围,只显示海洋部分colormap((m_colmap('blues',200)));  % 设置色标为m_map自带的m_colmap('blues')
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_etopo2('shadedrelief','lightangle',45); % 设置光源方位角为45°m_gshhs('ic','patch',[.6 .6 .6]); % 设置中等分辨率海岸线填充m_grid('box','fancy','gridlines','no','fontsize',14);  % 轴设置set(gcf,'position',[100 100 800 500]) %图形大小设置
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

3.3 例3

使用m_etopo2('shadedrelief'),光源方位角设置为45°,坡角阈值设置为1°。


figname='shadedrelief3';m_proj('mercator','long',[114 124],'lat',[20 26]);caxis([-5000 0]);    % 设置显示高程范围,只显示海洋部分colormap((m_colmap('blues',200)));  % 设置色标为m_map自带的m_colmap('blues')
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_etopo2('shadedrelief','lightangle',45,'gradient',1); % 设置光源方位角为45°,坡角阈值为1m_gshhs('ic','patch',[.6 .6 .6]);   % 设置中等分辨率海岸线填充m_grid('box','fancy','gridlines','no','fontsize',14);  % 轴设置set(gcf,'position',[100 100 800 500]) %图形大小设置
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

3.4 例4

使用m_shadedrelief,默认设置(光源方位角设置为-45°,坡角阈值设置为10°)。

figname='shadedrelief4';m_proj('mercator','long',[114 124],'lat',[20 26]);
[ELEV,LON,LAT]=m_etopo2([114 124 20 26]);
caxis([-5000 3000])
% %caxis要放在colormap之前,colormap要放在m_shadedrelief之前
% 使用两种色标区分陆地海洋,范围比例要和caxis匹配
colormap([m_colmap('blues',200);m_colmap('gland',120)])
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_shadedrelief(LON(1,:),LAT(:,1),ELEV)
m_gshhs('ic','color','k')m_grid('box','fancy','tickdir','in','gridlines','no','fontsize',14)set(gcf,'position',[100 100 800 500])
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

3.5 例5

使用m_shadedrelief,光源方位角设置为45°,坡角阈值设置为3°。

figname='shadedrelief5';m_proj('mercator','long',[114 124],'lat',[20 26]);
[ELEV,LON,LAT]=m_etopo2([114 124 20 26]);
caxis([-5000 3000])
% %caxis要放在colormap之前,colormap要放在m_shadedrelief之前
% 使用两种色标区分陆地海洋,范围比例要和caxis匹配
colormap([m_colmap('blues',200);m_colmap('gland',120)])
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_shadedrelief(LON(1,:),LAT(:,1),ELEV,'lightangle',45,'gradient',3)
m_gshhs('ic','color','k')m_grid('box','fancy','tickdir','in','gridlines','no','fontsize',14)set(gcf,'position',[100 100 800 500])
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

3.6 例6

在例5(使用m_shadedrelief,光源方位角设置为45°,坡角阈值设置为3°。)的基础上,添加河流,顺便改一下轴类型。

figname='shadedrelief6';
figure
m_proj('mercator','long',[114 124],'lat',[20 26]);
[ELEV,LON,LAT]=m_etopo2([114 124 20 26]);
caxis([-5000 3000])
% %caxis要放在colormap之前,colormap要放在m_shadedrelief之前
% 使用两种色标区分陆地海洋,范围比例要和caxis匹配
colormap([m_colmap('blues',200);m_colmap('gland',120)])
hc=colorbar;
set(get(hc,'title'),'string','Elevation(m)')  %  色标单位m_shadedrelief(LON(1,:),LAT(:,1),ELEV,'lightangle',45,'gradient',3)
m_gshhs('ic','color','k')   % 中等分辨率海岸线
m_gshhs('ir4','color','b')  % 中等分辨率河流m_grid('box','fancy','tickdir','out','gridlines','no','fontsize',14)set(gcf,'position',[100 100 800 500])
print('-dpng','-r600',[figname,'.png'])  % 导出png图片

暂时先写这些。

END

Matlab下地形图绘图包m_map绘制晕渲(shaded relief)地形图相关推荐

  1. Matlab下地形图绘图包m_map绘图包绘制高分辨率海岸线、国界线与河流

    1. 前言 之前说了m_map的下载.安装与基本使用(Matlab下地形图绘图包m_map安装与使用),以及晕渲地形图的绘制(m_map绘制晕渲(shaded relief)地形图),现在再说一下高分 ...

  2. Matlab下地形图绘图包m_map安装与使用

    〇.引言 m_map是Matlab下用于绘制地图的工具箱,和GMT有些相似. 1. 文档 m_map官网:https://www.eoas.ubc.ca/~rich/mapug.html 用法可以参考 ...

  3. 【MATLAB】基本绘图 ( plot 函数绘制多个图形 | legend 函数标注图形 | 图形修饰 )

    文章目录 一.plot 函数绘制多个图形 二.legend 函数标注图形 三.图形修饰 一.plot 函数绘制多个图形 使用单个 plot 函数绘制多条曲线 : plot 函数可以传入多个可变参数 , ...

  4. matlab如何画一个圆柱,matlab下在空间任意位置绘制圆柱

    参考链接:https://blog.csdn.net/weixin_44492796/article/details/88583536 绘制圆柱需要提供上底面和下底面的圆心的绝对坐标.以及半径.通过得 ...

  5. 【TikZ 简单学习(下):基础绘制】Latex下的绘图宏包

    [TikZ 简单学习[下]:基础绘制]Latex下的绘图宏包 上文 绘制多个节点 给节点添加统一样式 给节点命名 使用相对位置绘制 给节点标签 链接边的绘制 在线边上添加标签 绘制蛇形线和多行文本 层 ...

  6. MATLAB 长度和像素_气象编程 | Matlab教程:nc文件的打开和使用m_map绘制海温图

    添加新云天气象主编微信或QQ:130188121,及时获取或发布气象升学.就业.会议.征稿及学术动态等信息! 近期招聘.培训安排(点击图片了解详情): 在大气科学中,matlab可以用于小规模的科学计 ...

  7. Windows下的Matlab与Java的混合编程,Java调用matlab编译的jar包(linux下请看我另外版本!)

    近来因为甲方需要做拟合等功能,需要用到matlab软件,并将其功能在java中实现,然后在服务器上也要实现,因为之前根本没有听说过,所以我苦心泣血,狂干一星期找到了,踩了无数个坑,终于实现了,因此想分 ...

  8. linux下安装绘图的包numpy,scipy,matplotlibm

    原文链接:https://blog.csdn.net/Yakumoyukarilan/article/details/51340358 安装工作将在终端里进行,安装之前查看是否安装了python,如下 ...

  9. Matlab系列之绘图基础

    Matlab系列之绘图基础 前言 图形句柄与对象 对象属性 应用实例 运行结果 图形句柄的创建 图形窗口对象 实例程序 运行效果 坐标轴对象 实例程序 运行效果 曲线对象 实例程序 运行效果 文字对象 ...

最新文章

  1. 扩展gcd codevs 1200 同余方程
  2. 45.Keepalived高可用群集
  3. SAP CRM和Cloud for Customer的扩展字段元数据
  4. 前端和后端的英文_前端工程师一般都喜欢去哪些网站逛?
  5. JavaScript 之arguments、caller 和 callee 介绍
  6. bzoj 1647: [Usaco2007 Open]Fliptile 翻格子游戏(枚举)
  7. Linux 基本命令(一)--ls 常用命令
  8. Flutter之RenderView RenderObject ParentData知识点梳理
  9. 【语音识别】基于matlab傅立叶变换0-9数字语音识别【含Matlab源码 384期】
  10. Pikachu靶机系列之目录遍历、任意文件下载、敏感信息泄露、越权
  11. 斯皮尔曼相关系数范围_斯皮尔曼相关系数
  12. Firebug调试工具
  13. 1、多线程原理与实践 《Java高并发核心编程 卷二》读书笔记
  14. 华为 M5680t对HGU ONU配置指导
  15. 三三速记英语 需要者看
  16. 网络姻缘一线牵 大数据精准推广才能让合适的产品遇到合适的人!
  17. 算法题之创造新世界(动态规划)
  18. 青少年蓝桥杯python组(STEMA中级组)
  19. php cakephp like,CakePHP
  20. ReadBook-我的设置

热门文章

  1. SharePoint 2010 电子书下载网站推荐
  2. 机器学习与网络安全(一)
  3. python好学吗要有什么基础-Python好学吗难不难?0基础能学会吗?
  4. UEditor(集成 135 编辑器插件)(附源码)
  5. android软件开发
  6. [青少年CTF]misc-Simpleness writeup by q1jun
  7. python应用内部审计_基于大数据技术提升内部审计质量的路径
  8. bailian.openjudge 1190:生日蛋糕
  9. Jupyter notebook使用类错误提示 takes no arguments
  10. 二维码图片如何快速生成