0001 function par_resample_grid(sourcename,targetname,asciiout)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 disp('Reading in Source')
0015 [sxcoords,sycoords,srtm,sheader]=asciigrid2mat([sourcename]);
0016 disp('Done...')
0017
0018 disp('Reading in Target')
0019 [gxcoords,gycoords,globe,gheader]=asciigrid2mat([targetname]);
0020 disp('Done...')
0021
0022
0023
0024
0025 disp('Resampling Source to Target resolution using mean of cells and snapping to Target grid.')
0026 newsrtm=zeros(size(gycoords,2),size(gxcoords,2));
0027 for rows = 1:size(globe,1);
0028 for cols = 1:size(globe,2);
0029 newsrtm(rows,cols) = resample_mean(sheader.cellsize,gheader.cellsize, gxcoords(cols), gycoords(rows),min(sxcoords),min(sycoords), srtm);
0030 end;
0031 end;
0032 disp('Done...')
0033 clear srtm;
0034
0035
0036
0037
0038
0039 if (max(gxcoords)-min(gxcoords))*(max(gycoords)-min(gycoords)) > (max(sxcoords)-min(sxcoords))*(max(sycoords)-min(sycoords))
0040 disp('Cropping NaN borders on grids.')
0041 [gxcoords,gycoords,globe,newsrtm] = crop_compare_nan2(gxcoords,gycoords,globe,newsrtm);
0042 end
0043
0044 mat2grid([asciiout],gxcoords,gycoords,newsrtm)