-
Notifications
You must be signed in to change notification settings - Fork 0
/
tif2dat.m
executable file
·38 lines (30 loc) · 997 Bytes
/
tif2dat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
clear;
pni='/Volumes/hydroData/WestUS_Data/MODSCAG/UpperColoradoRiver/Geographic/';
pno='/Volumes/COSWE/SWE_SNODIS/recon/snodis/input_fsca/';
mkdir([pno,'UpperColoradoRiver/',num2str(yr)]);
for yr=2013:2013
if(leapyear(yr))
numdays=366;
else
numdays=365;
end
undefi=-9999;
undefo=-9999;
outfile=[pno,'UpperColoradoRiver/',num2str(yr),'/',num2str(yr),'.dat'];
fid=fopen(outfile,'w');
data=ones(1950,2580)*undefo;
for cnt=1:numdays
infile=[pni,num2str(yr),num2str(cnt,'%03i'),'.tif'];
if(exist(infile,'file'))
data=geotiffread(infile);
data(data==undefi)=NaN;
data=flipud(data);
data=data';
data(isnan(data))=undefo;
end
fwrite(fid,data,'real*4');
disp([num2str(yr),num2str(cnt,'%03i'),'.tif processed; [',num2str(size(data)),'] elements written.' ]);
end
fclose(fid);
end
disp('Done.');