02 - matlab m_map地学绘图工具基础函数 - m_proj


0. 引言

  上篇简述了m_map中所有函数及其功能,调用m_demo函数展示了m_map内置的15个示例。下面开始正式对各函数进行介绍。本篇介绍m_proj函数,该函数用于初始化投影方式,对绘制地学图件尤为重要。

  地图投影是利用一定数学法则把地球表面的经、纬线转换到平面上的理论和方法。由于地球是一个赤道略宽两极略扁的不规则的梨形球体,故其表面是一个不可展平的曲面,所以运用任何数学方法进行这种转换都会产生误差和变形,为按照不同的需求缩小误差,就产生了各种投影方式。m_map中包含了几乎所有常见的投影方式。

1. 查看所有投影方式

  在Matlab中执行m_proj('set')可以看到m_map支持的所有投影方式,如下:

>> m_proj('set')
     Stereographic 极射赤面投影法
     Orthographic 正射投影
     Azimuthal Equal-area 方位等面积投影
     Azimuthal Equidistant 等距方位投影
     Gnomonic 方位投影
     Satellite 卫星投影
     Albers Equal-Area Conic 圆锥等面积投影
     Lambert Conformal Conic Lambert 圆锥保角投影
     Mercator 墨卡托投影
     Miller Cylindrical  Miller 圆柱投影
     Equidistant Cylindrical 圆柱等距投影
     Cylindrical Equal-Area 等角圆柱投影
     Oblique Mercator 倾斜 Mercator 投影
     Transverse Mercator 横轴 Mercator 投影
     Sinusoidal 正弦曲线投影
     Gall-Peters 高尔-彼得斯投影
     Hammer-Aitoff 埃托夫 (Aitoff) 投影
     Mollweide 伪圆柱等面积投影
     Robinson Robinson 投影
     Kavrayski VII
     UTM 通用横轴 Mercator 投影

  m_proj('set')后面加上投影名称(proj_name)参数,可以看到每种投影所要输入的参数。由此就可以根据自己需要选择方式开始绘图了。

m_proj('set',proj_name)

示例:

>> m_proj('set','Stereographic')
     'Stereographic'                                                            
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>   

3. 各投影方式绘图示例

3.1 极射赤面投影法(Stereographic )

m_proj('set','Stereographic')
     'Stereographic'                                                            
     <,'lon<gitude>',center_long>  % 投影中心经纬度                                             
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>    % 控制将图绘制到                            
     <,'rot<angle>', degrees CCW>  
%% 示例代码
close all;clc;clear;
m_proj('stereographic','lon',0,'lat',90,'radius',90); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

Stereographic 投影图示


3.2 Orthographic 正射投影示例

m_proj('set','Orthographic')
     'Orthographic'                                                             
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>      
%% 示例代码
close all;clc;clear;
m_proj('Orthographic','lon',0,'lat',90,'radius',90,'rec','on'); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.3 Azimuthal Equal-area 方位等面积投影

m_proj('set','Azimuthal Equal-area')
     'Azimuthal Equal-area'                                                     
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>
%% 示例代码
close all;clc;clear;
m_proj('Azimuthal Equal-area','lon',0,'lat',90,'radius',90,'rec','on'); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.4 Azimuthal Equidistant 等距方位投影

m_proj('set','Azimuthal Equidistant')
     'Azimuthal Equidistant'                                                    
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>   
%% 示例代码
close all;clc;clear;
m_proj('Azimuthal Equidistant','lon',0,'lat',90,'radius',90,'rec','on'); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.5 Gnomonic 方位投影

 m_proj('set','Gnomonic')
     'Gnomonic'                                                                 
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>   
%% 示例代码
close all;clc;clear;
m_proj('Gnomonic','lon',0,'lat',90,'radius',90,'rec','on'); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.6 Satellite 卫星投影

m_proj('set','Satellite')
     'Satellite'                                                                
     <,'lon<gitude>',center_long>                                               
     <,'lat<itude>', center_lat>                                                
     <,'rad<ius>', ( degrees | [longitude latitude] ) | 'alt<itude>', alt_frac >
     <,'rec<tbox>', ( 'on' | 'off' | 'circle' )>                                
     <,'rot<angle>', degrees CCW>   
%% 示例代码
close all;clc;clear;
m_proj('Satellite','lon',0,'lat',90,'radius',90,'rec','off'); %设置投影中心位置和半径
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.7 Albers Equal-Area Conic 圆锥等面积投影

m_proj('set','Albers Equal-Area Conic')
     'Albers Equal-Area Conic'       
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'par<allels>',[lat1 lat2]>    
     <,'rec<tbox>', ( 'on' | 'off' )>
     <,'ell<ipsoid>', one of         
         normal                      
         sphere                      
          grs80                      
          grs67                      
          wgs84                      
          wgs72                      
          wgs66                      
          wgs60                      
         clrk66                      
         clrk80                      
         intl24                      
         intl67                      
                               >     
     <,'ori<gin>', [long lat]>    
%% 示例代码
close all;clc;clear;
m_proj('albers equal-area','lat',[40 60],'long',[-90 -50],'rect','on','ell','wgs84'); % 输入经纬度范围、
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.8 Lambert Conformal Conic Lambert 圆锥保角投影

m_proj('set','Lambert Conformal Conic')
     'Lambert Conformal Conic'       
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'par<allels>',[lat1 lat2]>    
     <,'rec<tbox>', ( 'on' | 'off' )>
     <,'ell<ipsoid>', one of         
         normal                      
         sphere                      
          grs80                      
          grs67                      
          wgs84                      
          wgs72                      
          wgs66                      
          wgs60                      
         clrk66                      
         clrk80                      
         intl24                      
         intl67        
%% 示例代码
close all;clc;clear;
m_proj('lambert','lon',[-10 20],'lat',[33 48]); 
[CS,CH]=m_etopo2('contourf',[-5000:500:0 250:250:3000],'edgecolor','none');
 m_grid('linestyle','none','tickdir','out','linewidth',3);

colormap([ m_colmap('blues',80); m_colmap('gland',48)]);
brighten(.5);

ax=m_contfbar(1,[.5 .8],CS,CH);
title(ax,{'Level/m',''}); % Move up by inserting a blank line

3.9 Mercator 墨卡托投影

m_proj('set','Mercator')
     'Mercator'                            
     <,'lon<gitude>',( [min max] | center)>
     <,'lat<itude>',( maxlat | [min max]>  
     <,'sph<ere>', one of                  
         normal                            
         sphere                            
          grs80                            
          grs67                            
          wgs84                            
          wgs72                            
          wgs66                            
          wgs60                            
         clrk66                            
         clrk80                            
         intl24                            
         intl67    
%% 示例代码
close all;clc;clear;
m_proj('Mercator','lon',[-180 180],'lat',[-80 80]); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.10 Miller Cylindrical Miller 圆柱投影

m_proj('set','Miller Cylindrical')
     'Miller Cylindrical'                  
     <,'lon<gitude>',( [min max] | center)>
     <,'lat<itude>',( maxlat | [min max]>  
     <,'sph<ere>', one of                  
         normal                            
         sphere                            
          grs80                            
          grs67                            
          wgs84                            
          wgs72                            
          wgs66                            
          wgs60                            
         clrk66                            
         clrk80                            
         intl24                            
         intl67   
%% 示例代码
close all;clc;clear;
m_proj('miller','lat',[-77 77]); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.11 Equidistant Cylindrical 圆柱等距投影

m_proj('set','Equidistant Cylindrical')
     'Equidistant Cylindrical'             
     <,'lon<gitude>',( [min max] | center)>
     <,'lat<itude>',( maxlat | [min max]>  
     <,'sph<ere>', one of                  
         normal                            
         sphere                            
          grs80                            
          grs67                            
          wgs84                            
          wgs72                            
          wgs66                            
          wgs60                            
         clrk66                            
         clrk80                            
         intl24                            
         intl67
%% 示例代码
close all;clc;clear;
m_proj('equidistant Cylindrical','lon',[-180 180],'lat',[-77 77]); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.12 Cylindrical Equal-Area 等角圆柱投影

m_proj('set','Cylindrical Equal-Area')
     'Cylindrical Equal-Area'              
     <,'lon<gitude>',( [min max] | center)>
     <,'lat<itude>',( maxlat | [min max]>  
     <,'sph<ere>', one of                  
         normal                            
         sphere                            
          grs80                            
          grs67                            
          wgs84                            
          wgs72                            
          wgs66                            
          wgs60                            
         clrk66                            
         clrk80                            
         intl24                            
         intl67
%% 示例代码
close all;clc;clear;
m_proj('Cylindrical Equal-Area','lon',[-180 180],'lat',[-77 77]); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.13 Oblique Mercator 倾斜 Mercator 投影

 m_proj('set','Oblique Mercator')
     'Oblique Mercator'                           
     <,'lon<gitude>',[value1 value2]>             
     <,'lat<itude>',[value1 value2]>              
     <,'asp<ect>',value>                          
     <,'dir<ection>',( 'horizontal' | 'vertical' )
%% 示例代码
close all;clc;clear;
m_proj('Oblique Mercator','lat',[56 30],'lon',[-132 -120],'aspect',.8); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.14 Transverse Mercator 横轴 Mercator 投影

m_proj('set','Transverse Mercator')
     'Transverse Mercator'           
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Transverse Mercator','lat',[20 70],'lon',[-132 -60],'rec','on'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.15 Sinusoidal 正弦曲线投影

m_proj('set','Sinusoidal')
     'Sinusoidal'                    
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Sinusoidal','lat',[20 70],'lon',[-132 -60],'rec','on'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.16 Gall-Peters 高尔-彼得斯投影

m_proj('set','Gall-Peters')
     'Gall-Peters'                   
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Gall-Peters','lat',[20 70],'lon',[-132 -60],'rec','on'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.17 Hammer-Aitoff 埃托夫 (Aitoff) 投影

m_proj('set','Hammer-Aitoff')
     'Hammer-Aitoff'                 
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Hammer-Aitoff','lat',[20 70],'lon',[-132 -60],'rec','off'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.18 Mollweide 伪圆柱等面积投影

m_proj('set','Mollweide')
     'Mollweide'                     
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Mollweide','lat',[20 70],'lon',[-132 -60],'rec','off'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.19 Robinson Robinson 投影

m_proj('set','Robinson')
     'Robinson'                      
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Robinson','lat',[20 70],'lon',[-132 -60],'rec','off'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.20 Kavrayski VII

m_proj('set','Kavrayski VII')
     'Kavrayski VII'                 
     <,'lon<gitude>',[min max]>      
     <,'lat<itude>',[min max]>       
     <,'clo<ngitude>',value>         
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('Kavrayski VII','lat',[20 70],'lon',[-132 -60],'rec','off'); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

3.21 UTM 通用横轴 Mercator 投影

m_proj('set','UTM')
     'UTM'                            
     <,'lon<gitude>',[min max]>       
     <,'lat<itude>',[min max]>        
     <,'zon<e>',value>                
     <,'hem<isphere>',[1|0] (0 for N)>
     <,'ell<ipsoid>', one of          
         normal                       
         sphere                       
          grs80                       
          grs67                       
          wgs84                       
          wgs72                       
          wgs66                       
          wgs60                       
         clrk66                       
         clrk80                       
         intl24                       
         intl67                       
                               >      
     <,'rec<tbox>', ( 'on' | 'off' )>
%% 示例代码
close all;clc;clear;
m_proj('utm','ellipse','grs80','zone',45,'lat',[10 60],'long',[10 160]); % 输入经纬度范围
m_coast('patch','r');
m_grid('linest','-','xticklabels',[],'yticklabels',[]);

4. 结语

  本篇把m_map中所有投影方式都做了简单案例,有些参数没有进行尝试,在使用某种投影绘图前可以借助本篇的简单案例进行参数验证,或有助于绘制比较漂亮的图示。






😜
😜😜
😜😜😜😜

  • 20
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
“No map projection initialized - call m_proj first!”是一个错误提示信息,通常在使用地理信息系统软件或地图相关的编程代码时会遇到。该错误的意思是在进行地图投影前未进行地图投影初始化操作。 在地图投影中,地球的三维表面需要转换为二维平面以便进行地图绘制和分析等操作。不同的地图投影方法会通过数学模型来近似地球的形状,并将地球的曲面映射到平面上。在进行地图绘制之前,需要先配置和初始化地图投影,以确定使用哪种投影方法以及投影参数等相关信息。 若出现“No map projection initialized - call m_proj first!”的错误提示,说明在进行地图绘制或相关操作前没有先调用相应的地图投影初始化函数。可以通过在代码中添加合适的地图投影初始化函数来解决该问题,例如使用m_proj函数进行地图投影初始化。这个初始化函数会根据定义的参数来初始化地图投影。 例如,以下是一个使用Python的Basemap库示例代码,展示了如何初始化地图投影以解决该错误: ```python from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt # 创建一个地图投影对象 m = Basemap(projection='merc', resolution='l', llcrnrlat=-60, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180) # 初始化地图投影 m.proj() # 在地图上绘制一些内容 m.drawcoastlines() m.drawcountries() m.drawstates() m.fillcontinents(color='coral', lake_color='aqua') # 显示地图 plt.show() ``` 通过调用`m.proj()`函数,我们可以初始化Basemap对象的地图投影,然后可以像上面的示例代码那样在地图上绘制各种地理要素。 总之,为了解决“No map projection initialized - call m_proj first!”的错误,我们需要在进行地图绘制或相关操作之前先调用适当的地图投影初始化函数,并配置合适的投影参数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咋(za)说

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值