1
|
/* look for all .asc files in input dir
|
2
|
/* load them and split into 1 degree tiles
|
3
|
|
4
|
&if %:program%_ eq ARC_ &then grid
|
5
|
&if %:program%_ ne GRID_ &then
|
6
|
&return This program must be run from ARC or GRID.
|
7
|
|
8
|
/*note the directory path
|
9
|
&sv indir I:\NCEAS\topo\incoming\srtmv41
|
10
|
&sv tiledir I:\NCEAS\topo\tiles
|
11
|
&sv name srtmv41
|
12
|
&sv vernum 1
|
13
|
|
14
|
|
15
|
&do x = 1 &to 72
|
16
|
&if %x% > 9 &then &sv xn %x%; &else &sv xn 0%x%
|
17
|
&do y = 1 &to 36
|
18
|
&if %y% > 9 &then &sv yn %y%; &else &sv yn 0%y%
|
19
|
&sv ascfile %indir%\srtm_%xn%_%yn%.asc
|
20
|
&if [exists %ascfile% -file] &then
|
21
|
&do
|
22
|
&type Got %ascfile%
|
23
|
|
24
|
/* import the ASCII file
|
25
|
&sv tmpgrd [scratchname -dir -full]
|
26
|
/* &sv tmpgrd c:\workspace\xx00000 - was using for testing
|
27
|
/* &type Using %tmpgrd% as temporary grid
|
28
|
%tmpgrd% = asciigrid(%ascfile%)
|
29
|
|
30
|
/* determine x (long) and y (lat) range
|
31
|
&describe %tmpgrd%
|
32
|
&sv xmin %grd$xmin%
|
33
|
&sv ymin %grd$ymin%
|
34
|
&sv xmax %xmin% + 5
|
35
|
&sv ymax %ymin% + 5
|
36
|
&sv cell %grd$dx%
|
37
|
|
38
|
&type %xmin% %ymin% %xmax% %ymax%
|
39
|
|
40
|
&do x = %xmin% &to %xmax%
|
41
|
&if %x% < 0 &then &sv xtile w[round [abs %x%]]; &else &sv xtile e[round %x%]
|
42
|
&sv x1 %x% + 1
|
43
|
&do y = %ymin% &to %ymax%
|
44
|
&if %y% < 0 &then &sv ytile s[round [abs %y%]]; &else &sv ytile n[round %y%]
|
45
|
&sv y1 %y% + 1
|
46
|
setwindow %x% %y% %x1% %y1%
|
47
|
&type Tile %x% %y%
|
48
|
show setwindow
|
49
|
&sv tmptile [scratchname -dir -full]
|
50
|
&type Create tile %xtile%%ytile%
|
51
|
%tmptile% = %tmpgrd%
|
52
|
&describe %tmptile%
|
53
|
&if %grd$stdv% > 0 &then &do
|
54
|
/* grid is not all nodata
|
55
|
&sv dirname %tiledir%\%xtile%
|
56
|
&if ^ [exists %dirname% -directory] &then &sys mkdir %dirname%
|
57
|
&sv dirname %tiledir%\%xtile%\%ytile%
|
58
|
&if ^ [exists %dirname% -directory] &then &sys mkdir %dirname%
|
59
|
&sv dirname %tiledir%\%xtile%\%ytile%\%vernum%
|
60
|
&if ^ [exists %dirname% -directory] &then &sys mkdir %dirname%
|
61
|
&sv dirname %tiledir%\%xtile%\%ytile%\%vernum%\%name%
|
62
|
&if ^ [exists %dirname% -directory] &then &sys mkdir %dirname%
|
63
|
&sv gridname %dirname%\%xtile%%ytile%
|
64
|
&if [exists %gridname% -grid] &then &do
|
65
|
&type WARNING: did not expect to find %gridname%!
|
66
|
&end
|
67
|
&else &do
|
68
|
copy %tmptile% %dirname%\%xtile%%ytile%
|
69
|
&end
|
70
|
&end
|
71
|
kill %tmptile%
|
72
|
&end
|
73
|
&end
|
74
|
|
75
|
kill %tmpgrd%
|
76
|
|
77
|
&end
|
78
|
&end
|
79
|
&end
|