默认头像
路人甲
路人甲
  • 注册日期2006-05-23
  • 发帖数2
  • QQ
  • 铜币118枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2338回复:1

直接对SRTM90m进行栅格内插的程序代码

楼主#
更多 发布于:2008-05-19 12:03
直接对SRTM90m进行栅格内插的程序代码
喜欢0 评分0
默认头像
路人甲
路人甲
  • 注册日期2006-05-23
  • 发帖数2
  • QQ
  • 铜币118枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2008-05-30 12:44

没学过MATLAB谁能帮我改成vb

function srtmfil(file_name1,file_name2,num,method)
% SRTM data processing..............................................
% Function: srtmfil V1.0
% Fills the blank hole of SRTM3 data set
% Use Matlab 'griddata' function
% Usage:
% srtmfil(input_file_name,output_file_name,size_of_srtm_matrix,interpolation_method)
% size_of_srtm_matrix: 1201 for SRTM3, 3601 for SRTM1
% interpolation_method: Switch from 1-4
% 1= 'linear' - Triangle-based linear interpolation (default).
% 2= 'cubic' - Triangle-based cubic interpolation.
% 3= 'nearest' - Nearest neighbor interpolation.
%
% Programed by:
% Frank Chen @
www.LVYE.ORG
% History:
% V1.0 : 11-Jan-2004 on Matlab 6.1.0, by Frank chen
%

% Read the SRTM data into memory...
display('Read SRTM data ....')
fid=fopen(file_name1,'r','s');
[Z0,n]=fread(fid,[num,num],'int16');
fclose(fid);

% Process data set band by band to solve memory limitation problem...
% band width=100 ; step = 50 for SRTM3 data

b_width=100;b_step=50;

for band=1:b_step:num-b_width

display(band)

% Cut a band for processing...
Zi=Z0(band:band+b_width, 1:num);
size(Zi);

%% meshgrid
[Xi,Yi]=meshgrid(1:num,band:band+b_width);
size(Xi);

%display('srtm data sorting....')
a=[Xi(:) Yi(:) Zi(:)];
b=sortrows(a,3);
[m,n]=size(b);

%display('srtm data sorting finished....')
for i=1:m
if(b(i,3) > -2000)
j=i;
break;
end
end

% b1=b(1:j-1,:);
% b1=sortrows(b1,[1 2]);
% size(b1)

b2=b(j:m,:);
b2=sortrows(b2,[1 2]);
size(b2);

% SRTM data griding ....
x=b2(:,1); y=b2(:,2); z=b2(:,3);

switch method
case 1,
Zi=griddata(x,y,z,Xi,Yi, 'linear');
case 2,
Zi=griddata(x,y,z,Xi,Yi, 'cubic');
case 3,
Zi=griddata(x,y,z,Xi,Yi, 'nearest');
otherwise,
Zi=griddata(x,y,z,Xi,Yi, 'linear');
end

size(Zi);
% merge the bands .....
if band ==1 Z = Zi(1:b_width-(b_step/2)-1,: );
elseif band==num-b_width Z=[Z ; Zi((b_step/2):b_width+1, :)];
else Z=[Z ; Zi((b_step/2):b_width-(b_step/2)-1,:)];
end
size(Z)

% loop control of bands...
end

% SRTM data saving ....
fid=fopen(file_name2,'w','s')
fwrite(fid,Z,'int16');
fclose(fid);

举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部