爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6758|回复: 4

[资源分享] GSHHS coastline to Surfer bln

[复制链接]

新浪微博达人勋

发表于 2011-11-29 20:26:33 | 显示全部楼层 |阅读模式

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

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

x
此贴转自:http://blog.sina.com.cn/s/blog_65f2ef3d0100s5q5.html

1.利用GSHHS自带的matlab程序获取想要的区域经纬度。如:

%  This Matlab script extracts coastline data from GSHHS database.

job='seagrid';            % Prepare coastlines for SeaGrid tool
%job='ploting';            % Prepare coastlines for NCAR ploting programs

database='full';          % Full resolution database
�tabase='high';          % High resolution database
�tabase='intermediate';  % Intermediate resolution database
�tabase='low';           % Low resolution database
�tabase='crude';         % crude resolution database

switch job,
  case 'seagrid'
    Oname='sb_coast.mat';
  case 'ploting'
    Oname='ch_coast.cst';
end,

switch database,
  case 'full'
    Cname='gshhs_f.b';
    name='gshhs_f.b';
  case 'high'
    Cname='gshhs_h.b';
    name='gshhs_h.b';
  case 'intermediate'
    Cname='gshhs_i.b';
    name='gshhs_i.b';
  case 'low'
    Cname='gshhs_l.b';
    name='gshhs_l.b';
  case 'crude'
    Cname='gshhs_c.b';
    name='gshhs_c.b';
end,

Llon=119;               % Left   corner longitude
Rlon=125;              % Right  corner longitude
Blat=27;                 % Bottom corner latitude
Tlat=37;                % Top    corner latitude

spval=9999.0;               % Special value

%----------------------------------------------------------------------------
%  Extract coastlines from GSHHS database.
%----------------------------------------------------------------------------

disp(['Reading GSHHS database: ',name]);
[C]=r_gshhs(Llon,Rlon,Blat,Tlat,Cname);

disp(['Processing read coastline data']);
switch job,
  case 'seagrid'
    [CC]=x_gshhs(Llon,Rlon,Blat,Tlat,C,'patch');
  case 'ploting'
    [C]=x_gshhs(Llon,Rlon,Blat,Tlat,C,'on');
end,

%----------------------------------------------------------------------------
%  Save extrated coastlines.
%----------------------------------------------------------------------------

lon=C.lon;
lat=C.lat;

switch job,
  case 'seagrid'
    save(Oname,'lon','lat');
  case 'ploting'
    x=lon;
    y=lat;
    ind=find(isnan(x));
    if (~isempty(ind)),
      x(ind)=C.type;
      y(ind)=spval;
    end,
    fid=fopen(Oname,'w');
    if (fid ~= -1),
      for i=1:length(x),
        fprintf(fid,'.6f  .6f\n',y(i),x(i));
      end,
      fclose(fid);
    end,
end,


2. 再将其转化为surfer的bln文件。代码:
clear all
% this is for GSHHS getted coast transformation to surfer ones!

% the yzcoast_coast.mat is getted from r_gshhhs.m function in the extract.m

load sb_coast.mat
lon(find(lon<119))=119;
lon(find(lon>125))=125;

lat(find(lat<27))=27;

lat(find(lat>37))=37;
nlon=lon;
nlat=lat;
i=length(lon);
while i>1
    temp=i-1;
    j=temp;
    while ~isnan(lon(j))
        j=j-1;
    end
    nlon(i)=temp-j;
    nlat(i)=0;
    i=j;
end


% i=length(lat);
% while i>1
%     temp=i-1;
%     j=temp;
%     while ~isnan(lat(j))
%         j=j-1;
%     end
%     nlat(i)=0;
%     i=j;
% end



a=[flipud(nlon) flipud(nlat)];



a=a(1:length(a)-1,:);

fid=fopen('sb_coast.bln','a');
for i=1:length(a)
    if a(i,2)==0
       fprintf(fid,'%d %d\n',a(i,:));
    else
        fprintf(fid,'%3.6f %3.6f\n',a(i,:));
    end
end
fclose(fid)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

0
早起挑战累计收入
发表于 2011-11-29 21:52:40 | 显示全部楼层
不错,surfer的底图来源方法也越来越多了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-9-11 22:54:05 | 显示全部楼层
兄台试过这个程序吗,我试了一下,好像有不少错误
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-5-7 08:16:20 | 显示全部楼层
一直在找这个转化方法,不知道能行吗。多谢。。。。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-5-7 08:49:14 | 显示全部楼层
程序不能用啊。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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