爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9623|回复: 8

[讨论] 关于gshhs安装的问题

[复制链接]

新浪微博达人勋

发表于 2019-5-28 10:39:50 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 Isakting 于 2019-5-28 10:44 编辑

以前安装过gshhs,也能够正常使用,后来重做系统后再安装的时候就出现了如下问题

>> m_gshhs_l
警告: Coastline file private/gshhs_l.b not found \n(Have you installed it? See the M_Map User's Guide for details)\n ---Using default coastline
instead
> In mu_coast>get_coasts (line 460)
  In mu_coast (line 101)
  In m_gshhs (line 114)
  In m_gshhs_l (line 28)

题主已经按照要求将gshhs相关文件放到了D:\MATLAB2016\toolbox\m_map\private 中,出现了如上错误
题主找到之前有遇到这种问题的,https://www.ilovematlab.cn/thread-277337-1-1.html 他是将每一个m_gshhs_*.m里面的FILENAME都改了
但是我的m_map中的m_gshhs_*.m并没有FILENAME这一行,而是集合到了m_gshhs.m这个脚本里
所以将m_gshhs.m里面的FILENAME也改成了 FILENAME="D:\MATLAB2016\toolbox\m_map\private\",但是依然无效
再然后题主还在http://compgroups.net/comp.soft-sys.matlab/problem-with-m_map-and-gshhs/393609这篇帖子中看到
I found a bug in function loading the GSHHS. Recently, the number of arguments in the header of polygon stored in GSHHS files have changed.However, I had some trouble loading GSHHS files.Looking inside the code, I found that the number of elements read in the header of each polygon did not match the GSHHS file.It has changed from 8 to 11ftp://ftp.soest.hawaii.edu/pwessel/gshhs/README.TXTIn file 'mu_coast.m' for function '[A,cnt] = get_gheader(fid)'I had to change the line [A,cnt]=fread(fid,8,'int32');to [A,cnt]=fread(fid,11,'int32'); where 11 is the new number of elements to read in the header.Without this change, nothing was displayed.The maintainer of this toolbox is aware of this bug , and will try to solve it.
就是说在上述错误中的mu_coast.m脚本中的读取多边形的元素个数不匹配(从8变成了11)


% Now, in the calling code I have to use A(2),A(3),A(5-7), A(8), A(9) from original.
[A,cnt]=fread(fid,8,'int32');

这行在mu_coast.m中的720行,然而修改为11后没有什么作用。
我使用的是gshhg-bin-2.3.7和最新的m_map,当然gshhs_1.0和2.0版本这些我也都试过,都用不了
我也不知道到底是哪儿出的问题,能试的方法我都试了,请问各位大佬有什么好的解决办法吗?



密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 32430
发表于 2019-6-1 10:55:59 | 显示全部楼层
楼主说:
我的m_map中的m_gshhs_*.m并没有FILENAME这一行

建议楼主把程序放出来,我告诉楼主在哪里
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-6-1 19:59:30 | 显示全部楼层
本帖最后由 Isakting 于 2019-6-1 20:02 编辑
二爷名声在外 发表于 2019-6-1 10:55
楼主说:
建议楼主把程序放出来,我告诉楼主在哪里

这个是我的m_gshhs.m 脚本文件,其中我认为需要修改的地方已经加粗标红
  1. function h=m_gshhs(resolution,varargin)
  2. % M_GSHHS Add a coastline to a given map using
  3. %           the Global Self-consistant Hierarchical High-resolution
  4. %           Shorelines, Rivers, and Borders
  5. %
  6. %         M_GSHHS(RES, (standard line option,...,...) ) draws the coastline
  7. %         river network, or borders as  simple lines.
  8. %
  9. %         M_GSHHS(RES,'patch' ( ,standard patch options,...,...) ) draws the
  10. %         coastline as a number of patches (rivers and borders are not
  11. %         arranged so patches can be drawn).
  12. %
  13. %         M_GSHHS(RES,'save',FILENAME) saves the extracted coastline data
  14. %         for the current projection in a file FILENAME. This allows
  15. %         speedier replotting using M_USERCOAST(FILENAME).
  16. %   
  17. %         RES: A one-char string (optionally 2 or 3)
  18. %         
  19. %         First char: resolution - one of
  20. %                      'c'  crude
  21. %                      'l'  low
  22. %                      'i'  intermediate
  23. %                      'h'  high
  24. %                      'f'  full
  25. %
  26. %         Second char: type - one of
  27. %                      'c' GSHHS coastline (default)
  28. %                      'b' WDB Border
  29. %                      'r' WDB River
  30. %  
  31. %         Third char - if 2nd char is 'b':
  32. %                      '1' Country borders
  33. %                      '2' State/Province and Country borders
  34. %                    - if 2nd char is 'r': '1','2','3','4'
  35. %                      add successively more tributaries
  36. %
  37. %         (also maintained is this optional format:
  38. %
  39. %         RES - selections resolution
  40. %                  1  or 'crude'       
  41. %                  2  or 'low'         
  42. %                  3  or 'intermediate'  
  43. %                  4  or 'high'        
  44. %                  5  or 'full         
  45. %
  46. %         but please don't use this).
  47. %
  48. %         See also M_PROJ, M_GRID, M_COAST, M_GSHHS_L, M_GSHHS_H, M_GSHHS_C
  49. %         M_USERCOAST   

  50. % Rich Pawlowicz (rich@ocgy.ubc.ca) 15/June/98
  51. %
  52. %
  53. % This software is provided "as is" without warranty of any kind. But
  54. % it's mine, so you can't sell it.
  55. %
  56. %  16/Dec/2005
  57. %*********************************************************************
  58. %  Modified after code provided by Bruce Lipphardt (brucel@udel.edu) to
  59. %  reduce the hierarchy of M_GSHHS_* routines to a single routine with a
  60. %  variable resolution input:
  61. % 20/Jan/2008 - added borders and rivers from gshhs v1.10
  62. % 4/DEc/11 - isstr to ischar
  63. % Sep/14 - added hierarchy to borders
  64. % Aug/18 - fixed error that occurred when called m_gshhs_X with 'save'
  65. %          option (Thanks to H. Grant for pointing this out).


  66. % Root of directories where all the gshhs_X.b, wdb_borders-X.b and wdb_rivers_X.b
  67. % files live
  68. <font color="#ff0000"><b>FILNAME='private/';</b></font>


  69. %-------------don't change below here----------------------------

  70. res_list = {'c','l','i','h','f'};
  71. typ_list={'c','b','r'};
  72. typ_names={'gshhs_','wdb_borders_','wdb_rivers_'};

  73. typ=1;
  74. flaglim='9';

  75. if ischar(resolution)
  76. if length(resolution)>=2
  77.    typ = find(strcmpi(resolution(2),typ_list));
  78. end
  79. if length(resolution)>=3
  80.    flaglim = resolution(3);
  81. end  
  82. resolution =  find(strcmpi(resolution(1),res_list));
  83. end


  84. if isempty(resolution) || resolution<1 || resolution> length(res_list)
  85.   error('**Don''t recognize the specified resolution');
  86. end
  87. if isempty(typ) || typ<1 || typ> length(res_list)
  88.   error('**Don''t recognize the specified type');
  89. end
  90.   
  91. res_char = res_list{resolution} ;
  92. file     = [FILNAME,sprintf('%s%s.b',typ_names{typ},res_char)] ;
  93. tag_name = sprintf('m_%s%s',typ_names{typ},res_char) ;


  94. % Set current projection to geographic
  95. Currentmap=m_coord('set');
  96. m_coord('geographic');


  97. if length(varargin)>1 && strcmp(varargin{1},'save')
  98.   [ncst,Area,k]=mu_coast(res_char,file);
  99.   save(varargin{2},'ncst','k','Area');
  100.   h=varargin{2};   % Error if you call m_gshhs_i with 'save' option - thanks HG, Aug/1/2018
  101. else
  102.   h=mu_coast([res_char flaglim],file,varargin{:},'tag',tag_name);
  103. end

  104. m_coord(Currentmap.name);

  105. if nargout==0
  106.     clear h
  107. end
复制代码

这个是我的m_gshhs_i.m脚本文件
  1. function h=m_gshhs_i(varargin)
  2. % M_GSHHS_I Add a coastline to a given map using the 'intermediate' resolution of
  3. %           the Global Self-consistant Hierarchical High-resolution
  4. %           Shorelines.
  5. %
  6. %         M_GSHHS_I( (standard line option,...,...) ) draws the coastline
  7. %         as a simple line.
  8. %         M_GSHHS_I('patch' ( ,standard patch options,...,...) ) draws the
  9. %         coastline as a number of patches.
  10. %
  11. %         M_GSHHS_I('save',FILENAME) saves the extracted coastline data
  12. %         for the current projection in a file FILENAME. This allows
  13. %         speedier replotting using M_USERCOAST(FILENAME).
  14. %   
  15. %         See also M_PROJ, M_GRID, M_COAST, M_GSHHS_L, M_GSHHS_H, M_GSHHS_C
  16. %         M_USERCOAST   

  17. % Rich Pawlowicz (rich@ocgy.ubc.ca) 15/June/98
  18. %
  19. %
  20. % This software is provided "as is" without warranty of any kind. But
  21. % it's mine, so you can't sell it.

  22. % Changes
  23. %  Nov/2017 - changed this into a stub calling gshhs.m (kept
  24. %             for backwards compatability)

  25. h=m_gshhs('ic',varargin{:});

复制代码


m_gshhs_*.m 其他分辨率的gshhs脚本也和第二个类似,应该是m_gshhs.m来调用对应分辨率的脚本吧?






密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 成长值: 32430
发表于 2019-7-8 21:59:24 | 显示全部楼层
不好意思现在才有时间回复楼主。
我也将我相应的程序的截图放上,供楼主比对
微信图片_20190708215749.png 微信图片_20190708215829.png
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-9-24 15:28:22 | 显示全部楼层
二爷名声在外 发表于 2019-7-8 21:59
不好意思现在才有时间回复楼主。
我也将我相应的程序的截图放上,供楼主比对

感谢!已经解决~!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-11-5 11:48:17 | 显示全部楼层
本帖最后由 kingjames 于 2019-11-5 12:04 编辑
Isakting 发表于 2019-9-24 15:28
感谢!已经解决~!

我也遇到了同样的问题,终于解决了  :FILNAME='D:\matlab2019a\toolbox\m_map\private/';
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-7-13 09:12:39 | 显示全部楼层
您好,请问您的m_gshhs_*.b文件是如何打开的?我的用记事本和matlab打开后,都是乱码
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-7-22 19:50:02 | 显示全部楼层
鼠国三 发表于 2020-7-13 09:12
您好,请问您的m_gshhs_*.b文件是如何打开的?我的用记事本和matlab打开后,都是乱码

不是.b 文件……是.m 脚本
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-8-25 17:03:13 | 显示全部楼层
请问你怎么解决的?我把m_gshhs.m文件里改了FILNAME='C:\Program Files\MATLAB\R2016a\toolbox\m_map\private\gshhs/',还是不行啊
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表