Project

General

Profile

« Previous | Next » 

Revision e1aa0df7

Added by selv in ga254@bulldogj about 11 years ago

setting for buldogJcluster; insert greenland ; impruved tiling

View differences:

terrain/procedures/dem_variables/gmted2010_res_x10/sc1_wget_gmted2010-30_bj.sh
1
# download  unzip and tif conversion of the Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010)
2
# setting working directory 
3

  
4

  
5

  
6

  
7
module load Tools/Python/2.7.3
8
module load Libraries/GDAL/1.10.0
9
module load Tools/PKTOOLS/2.4.2
10
module load Libraries/OSGEO/1.10.0
11

  
12

  
13
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
14
cd $INDIR
15

  
16
# download all the zip file from http://topotools.cr.usgs.gov/gmted_viewer/gmted2010_global_grids.php
17
# using multiprocess approch 
18

  
19
url=http://gmted.cr.usgs.gov/gmted/Grid_ZipFiles/
20

  
21

  
22
echo $url"be30_grd.zip" $url"ds30_grd.zip"  $url"mn30_grd.zip" | xargs -n 1 -P 7  wget  -d /lustre0/scratch/ga254/dem_bj/GMTED2010  $1   
23

  
24

  
25

  
26
# unzip the file using multiprocess approch  
27

  
28
ls  $INDIR/zip/??30_grd.zip | xargs -n 1 -P 7 bash -c $'
29
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
30
dir=`basename $1 .zip`
31
cd $INDIR/$dir
32

  
33
unzip   $1
34

  
35
' _ 
36

  
37

  
38
# transform to tif and tiling them using multiprocess approch   
39
# be30_grd.zip	Breakline Emphasis     , 30 arc-seconds
40
# ds30_grd.zip	Systematic Subsample   , 30 arc-seconds
41
# md30_grd.zip	Median Statistic       , 30 arc-seconds
42
# mi30_grd.zip	Minimum Statistic      , 30 arc-seconds
43
# mn30_grd.zip	Mean Statistic         , 30 arc-seconds
44
# mx30_grd.zip	Maximum Statistic      , 30 arc-seconds
45
# sd30_grd.zip	Standard Dev. Statistic, 30 arc-seconds
46

  
47
echo  be30_grd ds30_grd  mn30_grd |  xargs -n 1 -P 7 bash -c $'
48

  
49
dir=$1
50
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/$dir
51
        gdal_translate   -co COMPRESS=LZW $INDIR/$dir  $INDIR"_tif"/$dir.tif
52

  
53
' _ 
54

  
55
# at the end fo this process the 50 tiles tiff has been created for each of the defined component 
56

  
57

  
58

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc1_wget_gmted2010-7.5_bj.sh
1
# download  unzip and tif conversion of the Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010)
2
# setting working directory 
3

  
4
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
5
cd $INDIR
6

  
7
# download all the zip file from http://topotools.cr.usgs.gov/gmted_viewer/gmted2010_global_grids.php
8
# using multiprocess approch 
9

  
10
url=http://gmted.cr.usgs.gov/gmted/Grid_ZipFiles/
11

  
12
cd $INDIR/zip
13
echo $url"be75_grd.zip" $url"ds75_grd.zip" $url"md75_grd.zip" $url"mi75_grd.zip"  $url"mx75_grd.zip"  $url"sd75_grd.zip" | xargs -n 1 -P 7  wget  $1   
14

  
15

  
16

  
17

  
18
# $url"mn75_grd.zip"
19

  
20
# unzip the file using multiprocess approch  
21

  
22
ls  $INDIR/zip/??75_grd.zip | xargs -n 1 -P 7 bash -c $'
23
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
24
dir=`basename $1 .zip`
25
unzip  -d  $INDIR/tiles/$dir $1
26

  
27
' _ 
28

  
29

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc2_green_land_bj.sh
1

  
2

  
3
module load Tools/Python/2.7.3
4
module load Libraries/GDAL/1.10.0
5
module load Tools/PKTOOLS/2.4.2
6
module load Libraries/OSGEO/1.10.0
7

  
8

  
9
SHP=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/shp
10
REFER=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/reference_tif
11

  
12
rm -f $SHP/green_land30arc-sec.tif
13
gdal_rasterize  -co COMPRESS=LZW   -ot Byte  -a id -l green_land   -tr  0.008333333333333 0.008333333333333 -te $(/home2/ga254/bin/getCorners4Gwarp $REFER/geo30arcsec_reference.tif) $SHP/green_land.shp $SHP/green_land30arc-sec.tif 
14

  
15
geo_string=$(/home2/ga254/bin/oft-bb $SHP/green_land30arc-sec.tif   1 | grep BB | awk '{ print $6,$7,$8-$6,$9-$7 }')
16
# clip the tif 
17
gdal_translate -srcwin  $geo_string   -co COMPRESS=LZW  -ot Byte $SHP/green_land30arc-sec.tif  $SHP/green_land30arc-sec_msk.tif  
18

  
19
rm -f $SHP/green_land7.5arc-sec.tif
20

  
21
gdal_rasterize  -co COMPRESS=LZW   -ot Byte  -a id -l green_land   -tr 0.002083333333333 0.002083333333333  -te $(/home2/ga254/bin/getCorners4Gwarp $REFER/geo30arcsec_reference.tif) $SHP/green_land.shp $SHP/green_land7.5arc-sec.tif 
22

  
23
geo_string=$(/home2/ga254/bin/oft-bb $SHP/green_land7.5arc-sec.tif   1 | grep BB | awk '{ print $6,$7,$8-$6,$9-$7 }')
24
# clip the tif 
25
gdal_translate -srcwin  $geo_string   -co COMPRESS=LZW  -ot Byte $SHP/green_land7.5arc-sec.tif  $SHP/green_land7.5arc-sec_msk.tif  
26

  
27

  
28

  
29
# prepare the integration of greeland mn for mn md mx mn 
30

  
31
TILES=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles
32

  
33
rm -f $TILES/mn75_grd_tif/green_land.tif
34

  
35
gdalwarp -r cubic -te $(~/bin/getCorners4Gwarp  $TILES/shp/green_land7.5arc-sec_msk.tif )  -tr 0.002083333333333 0.002083333333333  $TILES/mn30_grd_tif/mn30_grd.tif $TILES/mn75_grd_tif/green_land.tif
36

  
37
pksetmask -i $TILES/mn75_grd_tif/green_land.tif -m $SHP/green_land7.5arc-sec_msk.tif  -t 0 -f 0 -o $TILES/mn75_grd_tif/green_land_msk.tif
38

  
39

  
40
rm -f $TILES/ds75_grd_tif/green_land.tif
41

  
42
gdalwarp -r cubic -te $(~/bin/getCorners4Gwarp  $TILES/shp/green_land7.5arc-sec_msk.tif )  -tr 0.002083333333333 0.002083333333333  $TILES/ds30_grd_tif/ds30_grd.tif $TILES/ds75_grd_tif/green_land.tif
43

  
44
pksetmask -i $TILES/ds75_grd_tif/green_land.tif -m $SHP/green_land7.5arc-sec_msk.tif  -t 0 -f 0 -o $TILES/ds75_grd_tif/green_land_msk.tif
45

  
46

  
47

  
48
rm -f $TILES/be75_grd_tif/green_land.tif
49

  
50
gdalwarp -r cubic -te $(~/bin/getCorners4Gwarp  $TILES/shp/green_land7.5arc-sec_msk.tif )  -tr 0.002083333333333 0.002083333333333  $TILES/be30_grd_tif/be30_grd.tif   $TILES/be75_grd_tif/green_land.tif
51

  
52
pksetmask -i $TILES/be75_grd_tif/green_land.tif -m $SHP/green_land7.5arc-sec_msk.tif  -t 0 -f 0 -o $TILES/be75_grd_tif/green_land_msk.tif
terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh
16 16

  
17 17
( 
18 18

  
19
echo altitude variables with file    $INDIR/$filename.tif 
20

  
21
#  median 
22
pkfilter -m -32768   -dx 4 -dy 4   -f median -d 4 -i  $INDIR/$filename.tif    -o  $OUTDIR/altitude/median/tiles/${filename}_${mm}.tif     -co COMPRESS=LZW -ot Int16  
23
# stdev
24
pkfilter -m -32768 -dx 4 -dy 4   -f var -d 4 -i $INDIR/$filename.tif   -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32   # max 1552385.000 sqrt(1245.947)
25
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/altitude/stdev/tiles/${filename}_${mm}.tif
26
rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
27
# min 
28
pkfilter -m -32768  -dx 4 -dy 4   -f min -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
29
# max
30
pkfilter -m -32768 -dx 4 -dy 4   -f max -d 4 -i $INDIR/$filename.tif    -o  $OUTDIR/altitude/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
31
# mean
32
pkfilter -m -32768 -dx 4 -dy 4   -f mean -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/mean/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW  -ot Int16  
33

  
34
# starting to use gdaldem to compute variables. Gdaldem use -9999 as no data. 
35

  
36
echo  slope with file   $INDIR/$filename.tif
37
gdaldem slope  -s 111120 -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/slope/tiles/${filename}_${mm}.tif  # -s to consider xy in degree and z in meters
38
# slope median 
39
pkfilter -m -9999 -dx 4 -dy 4 -f median  -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o $OUTDIR/slope/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Byte
40
# slope stdev 
41
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o   /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32
42
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/slope/stdev/tiles/${filename}_${mm}.tif
43
rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
44
# slope min 
45
pkfilter -m -9999  -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
46
# slope max
47
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
48
# slope mean
49
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -ot Byte 
50

  
51
# rm -f  $OUTDIR/slope/tiles/$filename.tif
52

  
53
echo  generate a Terrain Ruggedness Index TRI  with file   $file
54
gdaldem TRI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tri/tiles/${filename}_${mm}.tif
55
# tri median 
56
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o $OUTDIR/tri/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
57
# tri stdev 
58
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4    -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif
59
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/tri/stdev/tiles/${filename}_${mm}.tif
60
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
61
# tri min 
62
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16  
63
# tri max
64
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
65
# tri mean
66
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
67

  
68
# rm -f  $OUTDIR/tri/tiles/$filename.tif
69

  
70
echo  generate a Topographic Position Index TPI  with file   $INDIR/$filename.tif
71

  
72
gdaldem TPI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tpi/tiles/${filename}_${mm}.tif      # tpi has negative number 
73

  
74
oft-calc -ot Float32   $OUTDIR/tpi/tiles/${filename}_${mm}.tif $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  &> /dev/null    <<EOF
75
1
76
#1 10 *
77
EOF
78

  
79
# tpi median 
80
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o $OUTDIR/tpi/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
81
echo tpi stdev 
82
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o /tmp/ramdisk/tmp_${filename}_${mm}.tif 
83
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif  --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/tpi/stdev/tiles/${filename}_${mm}.tif
84
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
85
# tpi min 
86
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/min/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
87
# tpi max
88
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/max/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
89
# tpi mean
90
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
91

  
92

  
93
echo  generate roughness   with file   $INDIR/$filename.tif
94

  
95
gdaldem  roughness  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/roughness/tiles/${filename}_${mm}.tif
96

  
97
# roughness median 
98
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
99
echo roughness stdev 
100
pkfilter -m -9999 -dx 4 -dy 4 -f var  -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o /tmp/ramdisk/tmp_${filename}_${mm}.tif  
101
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/roughness/stdev/tiles/${filename}_${mm}.tif
102
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
103
# roughness min 
104
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
105
# roughness max
106
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
107
# roughness mean
108
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
109

  
110
# rm -f   $OUTDIR/roughness/tiles/${filename}_${mm}.tif
19
# echo altitude variables with file    $INDIR/$filename.tif 
20

  
21
# #  median 
22
# pkfilter -m -32768   -dx 4 -dy 4   -f median -d 4 -i  $INDIR/$filename.tif    -o  $OUTDIR/altitude/median/tiles/${filename}_${mm}.tif     -co COMPRESS=LZW -ot Int16  
23
# # stdev
24
# pkfilter -m -32768 -dx 4 -dy 4   -f var -d 4 -i $INDIR/$filename.tif   -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32   # max 1552385.000 sqrt(1245.947)
25
# gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/altitude/stdev/tiles/${filename}_${mm}.tif
26
# rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
27
# # min 
28
# pkfilter -m -32768  -dx 4 -dy 4   -f min -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
29
# # max
30
# pkfilter -m -32768 -dx 4 -dy 4   -f max -d 4 -i $INDIR/$filename.tif    -o  $OUTDIR/altitude/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
31
# # mean
32
# pkfilter -m -32768 -dx 4 -dy 4   -f mean -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/mean/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW  -ot Int16  
33

  
34
# # starting to use gdaldem to compute variables. Gdaldem use -9999 as no data. 
35

  
36
# echo  slope with file   $INDIR/$filename.tif
37
# gdaldem slope  -s 111120 -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/slope/tiles/${filename}_${mm}.tif  # -s to consider xy in degree and z in meters
38
# # slope median 
39
# pkfilter -m -9999 -dx 4 -dy 4 -f median  -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o $OUTDIR/slope/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Byte
40
# # slope stdev 
41
# pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o   /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32
42
# gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/slope/stdev/tiles/${filename}_${mm}.tif
43
# rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
44
# # slope min 
45
# pkfilter -m -9999  -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
46
# # slope max
47
# pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
48
# # slope mean
49
# pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -ot Byte 
50

  
51
# # rm -f  $OUTDIR/slope/tiles/$filename.tif
52

  
53
# echo  generate a Terrain Ruggedness Index TRI  with file   $file
54
# gdaldem TRI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tri/tiles/${filename}_${mm}.tif
55
# # tri median 
56
# pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o $OUTDIR/tri/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
57
# # tri stdev 
58
# pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4    -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif
59
# gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/tri/stdev/tiles/${filename}_${mm}.tif
60
# rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
61
# # tri min 
62
# pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16  
63
# # tri max
64
# pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
65
# # tri mean
66
# pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
67

  
68
# # rm -f  $OUTDIR/tri/tiles/$filename.tif
69

  
70
# echo  generate a Topographic Position Index TPI  with file   $INDIR/$filename.tif
71

  
72
# gdaldem TPI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tpi/tiles/${filename}_${mm}.tif      # tpi has negative number 
73

  
74
# oft-calc -ot Float32   $OUTDIR/tpi/tiles/${filename}_${mm}.tif $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  &> /dev/null    <<EOF
75
# 1
76
# #1 10 *
77
# EOF
78

  
79
# # tpi median 
80
# pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o $OUTDIR/tpi/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
81
# echo tpi stdev 
82
# pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o /tmp/ramdisk/tmp_${filename}_${mm}.tif 
83
# gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif  --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/tpi/stdev/tiles/${filename}_${mm}.tif
84
# rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
85
# # tpi min 
86
# pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/min/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
87
# # tpi max
88
# pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/max/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
89
# # tpi mean
90
# pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
91

  
92

  
93
# echo  generate roughness   with file   $INDIR/$filename.tif
94

  
95
# gdaldem  roughness  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/roughness/tiles/${filename}_${mm}.tif
96

  
97
# # roughness median 
98
# pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
99
# echo roughness stdev 
100
# pkfilter -m -9999 -dx 4 -dy 4 -f var  -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o /tmp/ramdisk/tmp_${filename}_${mm}.tif  
101
# gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/roughness/stdev/tiles/${filename}_${mm}.tif
102
# rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
103
# # roughness min 
104
# pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
105
# # roughness max
106
# pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
107
# # roughness mean
108
# pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
109

  
110
# # rm -f   $OUTDIR/roughness/tiles/${filename}_${mm}.tif
111 111

  
112 112

  
113 113
echo  aspect  with file   $INDIR/$filename.tif
terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
8 8

  
9 9
DIR=$1
10 10
mm=$2
11
INDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class${DIR}
12
INDIR_C=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class
11
INDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class${DIR}   # this has pixel value = 0.002083333333333
12
INDIR_C=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class       # this has pixel value = 0.002083333333333
13 13
OUTDIR=/mnt/data2/dem_variables/GMTED2010/altitude/percent_class_${mm}
14 14

  
15 15
rm  -f $OUTDIR/file_processed_sc3.txt  # the file has ben processed by the script sc1_dem_treshold_percent.sh
terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tiling_gmted2010-7.5_bj.sh
1
# download  unzip and tif conversion of the Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010)
2
# setting working directory 
3

  
4
# transform to tif and tiling them using multiprocess approch   
5
# be75_grd.zip	Breakline Emphasis     , 7.5 arc-seconds
6
# ds75_grd.zip	Systematic Subsample   , 7.5 arc-seconds
7
# md75_grd.zip	Median Statistic       , 7.5 arc-seconds
8
# mi75_grd.zip	Minimum Statistic      , 7.5 arc-seconds
9
# mn75_grd.zip	Mean Statistic         , 7.5 arc-seconds
10
# mx75_grd.zip	Maximum Statistic      , 7.5 arc-seconds
11
# sd75_grd.zip	Standard Dev. Statistic, 7.5 arc-seconds
12

  
13
# rm     /lustre0/scratch/ga254/stdout/*  /lustre0/scratch/ga254/stderr/*
14
# for DIR in  md75_grd mi75_grd mn75_grd mx75_grd be75_grd ds75_grd sd75_grd  ; do  qsub -v DIR=$DIR   /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tiling_gmted2010-7.5_bj.sh ; done
15

  
16
# for DIR in  md75_grd mi75_grd mn75_grd mx75_grd be75_grd ds75_grd sd75_grd  ; do  bash   /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tiling_gmted2010-7.5_bj.sh $DIR ; done
17

  
18

  
19
#PBS -S /bin/bash 
20
#PBS -q fas_normal
21
#PBS -l mem=4gb
22
#PBS -l walltime=4:00:00 
23
#PBS -l nodes=1:ppn=4
24
#PBS -V
25
#PBS -o /lustre0/scratch/ga254/stdout 
26
#PBS -e /lustre0/scratch/ga254/stderr
27

  
28

  
29
# DIR=$1
30

  
31
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles
32
cd $INDIR
33

  
34
# load moduels 
35

  
36
module load Tools/Python/2.7.3
37
module load Libraries/GDAL/1.10.0
38
module load Tools/PKTOOLS/2.4.2
39
module load Libraries/OSGEO/1.10.0
40

  
41

  
42
#              -projwin ulx uly lrx lry 
43
gdal_translate -projwin -180 +90   0   0  -co COMPRESS=LZW  -ot Int16   $INDIR/$DIR/$DIR $INDIR/$DIR"_tif"/$DIR"_NW.tif"
44
gdal_translate -projwin    0 +90 180   0  -co COMPRESS=LZW  -ot Int16   $INDIR/$DIR/$DIR $INDIR/$DIR"_tif"/$DIR"_NE.tif"
45
gdal_translate -projwin -180   0   0 -90  -co COMPRESS=LZW  -ot Int16   $INDIR/$DIR/$DIR $INDIR/$DIR"_tif"/$DIR"_SW.tif"
46
gdal_translate -projwin    0   0 180 -90  -co COMPRESS=LZW  -ot Int16   $INDIR/$DIR/$DIR $INDIR/$DIR"_tif"/$DIR"_SE.tif"
47

  
48

  
49
gdal_edit.py -a_ullr -180 +90   0   0      $INDIR/$DIR"_tif"/$DIR"_NW.tif"
50
gdal_edit.py -a_ullr    0 +90 180   0      $INDIR/$DIR"_tif"/$DIR"_NE.tif"
51
gdal_edit.py -a_ullr -180   0   0 -90      $INDIR/$DIR"_tif"/$DIR"_SW.tif"
52
gdal_edit.py -a_ullr    0   0 180 -90      $INDIR/$DIR"_tif"/$DIR"_SE.tif"
53

  
54
gdalbuildvrt -overwrite    $INDIR/$DIR"_tif"/$DIR.vrt  $INDIR/$DIR"_tif"/$DIR"_"??.tif
55

  
56

  
57

  
58
for nx in `seq 0 9` ; do  for ny in `seq 0 4` ; do echo $nx $ny $DIR; done ; done | xargs -n 3  -P 4  bash -c $'
59
nx=$1
60
ny=$2
61
DIR=$3
62
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/$DIR"_tif"
63

  
64
xoff=$(echo 17280 \* $nx | bc)
65
yoff=$(echo 2879 + 13440 \* $ny | bc)   # 2879 the ofset of no data value in the northen part
66
xsize=17296 # increase 16 pixel to avoid border effect, 4 in the aggregate version 
67
ysize=13456 # increase 16 pixel to avoid border effect 
68
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $INDIR/$DIR.vrt  $INDIR/$nx"_"$ny.tif
69

  
70
' _ 
71

  
72

  
73
rm $DIR"_tif"/${DIR}_??.tif
74

  
75
echo start to integrate greenland 
76

  
77

  
78
for tile in 2_0 3_0 4_0 2_1 3_1 4_1 ; do echo $tile $DIR ; done |  xargs -n 2  -P 6  bash -c $'
79

  
80
tile=$1
81
DIR=$2
82
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles
83

  
84
    # get greenland mn and paste in mn md mx mn be
85
    if [  $DIR = mn75_grd ] ||  [  $DIR=md75_grd  ] ||  [  $DIR=mx75_grd ]   ||  [  $DIR=mn75_grd  ] || $DIR = be75_grd ] ; then 
86
    echo $DIR  $tile 
87
pkmosaic -t 0 -min -30000 $(pkinfo -bb -i $INDIR/$DIR"_tif"/${tile}.tif) -co COMPRESS=LZW -co ZLEVEL=9 -m max -i $INDIR/$DIR"_tif"/${tile}.tif  -i $INDIR/mn75_grd_tif/green_land_msk.tif  -o $INDIR/$DIR"_tif"/${tile}g.tif
88
    fi 
89
    # get greenland ds and paste in ds 
90
    if [  $DIR = ds75_grd ]  ; then 
91
    echo $DIR $tile 
92
    pkmosaic -t 0 -min -30000 $(pkinfo -bb -i $INDIR/$DIR"_tif"/${tile}.tif) -co COMPRESS=LZW -co ZLEVEL=9  -m max  -i  $INDIR/$DIR"_tif"/${tile}.tif  -i $INDIR/ds75_grd_tif/green_land_msk.tif  -o $INDIR/$DIR"_tif"/${tile}g.tif
93
    fi 
94
    # standard deviation not computed for greenland becouse == to 0
95

  
96
mv $INDIR/$DIR"_tif"/${tile}.tif $INDIR/$DIR"_tif"/${tile}_no_green.tiff
97

  
98
mv $INDIR/$DIR"_tif"/${tile}g.tif $INDIR/$DIR"_tif"/${tile}.tif
99

  
100
' _ 
101

  
102

  
103

  
104

  
105

  
106

  
107

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc3a_dem_variables_merge.sh
1
# calculate different variables for the dem 
2
# for dir1  in altitude  ; do for dir2 in stdev ; do echo $dir1/$dir2 ; done ; done  | xargs -n 1 -P 5 bash /mnt/data2/dem_variables/scripts/sc2_dem_merge.sh
3
# for dir1  in altitude slope tri tpi roughness aspect ; do for dir2 in max mean median min stdev; do echo $dir1/$dir2 ds ; done ; done  | xargs -n 2 -P 12 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3a_dem_variables_merge.sh
4

  
5

  
6
OUTDIR=/mnt/data2/dem_variables/GMTED2010
7

  
8
DIR=$1
9
dir1=$(echo ${DIR%/*})   # cancel the part after  /
10
dir2=$(echo ${DIR#*/})   # cancel the part before /
11
mm=$2
12

  
13
if [ $dir1 = altitude ]  ; then type=Int16 ; fi 
14
if [ $dir1 = aspect ]    ; then type=Int16 ; fi  
15
if [ $dir1 = slope ]     ; then type=Byte ; fi  
16
if [ $dir1 = tri ]       ; then type=Int16 ; fi 
17
if [ $dir1 = tpi ]       ; then type=Int16 ; fi   
18
if [ $dir1 = roughness ] ; then type=Int16 ; fi 
19

  
20
if [ $dir1 != aspect ]; then 
21

  
22
echo processing merging tiles in $dir1   
23
           
24
rm -f $OUTDIR/$DIR/$dir1"_"$dir2.tif
25
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  
26
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  
27
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  
28
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif
29
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif
30

  
31
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[0-1]_?_${mm}.tif
32
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[2-3]_?_${mm}.tif
33
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[4-5]_?_${mm}.tif
34
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[6-7]_?_${mm}.tif
35
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[8-9]_?_${mm}.tif
36

  
37

  
38
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2.tif
39

  
40
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif   $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif 
41

  
42
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  
43
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  
44
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  
45
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif
46
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif
47

  
48
gdal_translate -co COMPRESS=LZW  -co ZLEVEL=9 $OUTDIR/$DIR/$dir1"_"$dir2.tif $OUTDIR/$DIR/${dir1}_${dir2}_${mm}.tif
49
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2.tif  
50

  
51
else  # just applaied to the aspect variables 
52

  
53
echo processing merging tiles for the different aspect variables in $dir1   
54

  
55
for aspect_var in "_sin_t10k" "_cos_t10k" "_Ew_t10k" "_Nw_t10k" ; do 
56

  
57
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif
58
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif
59
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif
60
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif
61
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
62

  
63
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[0-1]_?_${mm}$aspect_var.tif
64
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[2-3]_?_${mm}$aspect_var.tif 
65
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[4-5]_?_${mm}$aspect_var.tif
66
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[6-7]_?_${mm}$aspect_var.tif
67
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/[8-9]_?_${mm}$aspect_var.tif
68

  
69
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif
70

  
71
gdal_merge.py -o $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif -ot $type -co COMPRESS=LZW   $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif  $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif   $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
72

  
73
gdal_translate -co COMPRESS=LZW  -co ZLEVEL=9  $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif $OUTDIR/$DIR/${dir1}_${dir2}_${mm}_${aspect_var}.tif
74
rm -f $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif
75

  
76
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif
77
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif  
78
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif  
79
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif
80
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
81

  
82
done
83

  
84
fi 
85

  
86

  
87

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc4_pixel_correction_bj.sh
1
# correct immage with  anomalus pixel valus. 
2
# the file
3
# giuseppea@turaco:/mnt/data2/dem_variables/GMTED2010/altitude/class_mi$ pkinfo -hist -i   ../../tiles/mi75_grd_tif/5_1.tif  | more 
4
# -931 1  anomalus 
5
# -898 1  anomalus
6
# -498 1
7
# -461 1
8

  
9
# therefore the -931 -898 will be fill in withe the nearby pixel.
10

  
11
cd /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/mi75_grd_tif
12
cp  5_1.tif 5_1_orig.tiff
13
pkgetmask -co COMPRESS=LZW -i 5_1.tif  -min  -890 -max 10000 -t 1 -f 0 -o 5_1_mask.tif
14
pkfillnodata -i 5_1.tif  -m 5_1_mask.tif     -o 5_1_fill.tif
15
mv 5_1_fill.tif 5_1.tif
16
rm 5_1_mask.tif 
17

  
18
# corretta 
19

  
20
cd /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/
21

  
22
for dir in  md75_grd_tif be75_grd_tif ds75_grd_tif mn75_grd_tif ;do 
23
cd $dir 
24
cp  5_1.tif 5_1_orig.tiff
25
pkgetmask -co COMPRESS=LZW -i 5_1.tif  -min  -600  -max 10000 -t 1 -f 0 -o 5_1_mask.tif
26
pkfillnodata -i 5_1.tif  -m 5_1_mask.tif     -o 5_1_fill.tif
27
mv 5_1_fill.tif 5_1.tif
28
rm 5_1_mask.tif 
29
done 
30

  
31

  
32

  
33
# the values becom -93 and -80 
34

  
35
#  -93 2830
36
#  -93 2831
37
# 
38
#  -80 19449
39
#  -80 19450
40

  
41
## correction of a square box of 500 500 pixel. Set the value = to 179 as the near by pixel.
42
cd /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/
43

  
44
for dir in mi75_grd_tif mn75_grd_tif md75_grd_tif ds75_grd_tif be75_grd_tif mx75_grd_tif ; do
45

  
46
cd $dir 
47
gdal_translate  -srcwin  10070 3830 500 500   2_1.tif  2_1_clip.tif
48

  
49
pksetmask -co COMPRESS=LZW -t 0  -f 179   -i 2_1.tif   -m 2_1_clip.tif   -o 2_1_correct.tif 
50
mv 2_1.tif 2_1_orig.tiff
51
mv 2_1_correct.tif 2_1.tif 
52
rm 2_1_clip.tif
53
done
54

  
55

  
56
# correction of a square in the caspian sea set value to -27 
57
cd /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/
58

  
59
for dir in mx75_grd_tif  md75_grd_tif be75_grd_tif ds75_grd_tif mn75_grd_tif mi75_grd_tif  ;do 
60
cd $dir 
61
gdal_translate  -srcwin  5719 5249 1050 1050   6_1.tif  6_1_clip1.tif
62
gdal_translate  -srcwin  6200 6200 1050 550    6_1.tif  6_1_clip2.tif
63
gdal_translate  -srcwin  6700 6700 1050 550    6_1.tif  6_1_clip3.tif
64
gdal_translate  -srcwin  7150 7000 550  700    6_1.tif  6_1_clip4.tif
65
gdal_translate  -srcwin  6700 7550 1050 1100   6_1.tif  6_1_clip5.tif
66
gdal_translate  -srcwin  7150 8000 1050 1150   6_1.tif  6_1_clip6.tif
67

  
68
pksetmask -co COMPRESS=LZW -t 0 -f -27 -t 0 -f -27 -t 0 -f -27 -t 0 -f -27 -t 0 -f -27 -t 0 -f -27   -m 6_1_clip1.tif  -m 6_1_clip2.tif  -m 6_1_clip3.tif  -m 6_1_clip4.tif  -m 6_1_clip5.tif  -m 6_1_clip6.tif   -i 6_1.tif -o 6_1_correct.tif
69
mv  6_1.tif  6_1_orig.tiff
70
mv 6_1_correct.tif 6_1.tif
71
rm 6_1_clip*.tif
72

  
73
done 
74

  
75

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc5a_class_treshold_percent_bj.sh
1

  
2
# calculate altitude area percent above a specific treshold
3
# e.g  75% of class200 means that 75% of the pixels is >= 200 
4
# for this case the treshold is set every 100 meter
5
# geting the integer of the altitued / 100
6
# 230 become class 200
7
# 159 become class 100
8

  
9
#  for file in /mnt/data2/dem_variables/GMTED2010/tiles/mi75_grd_tif/*.tif ; do echo $file mi ; done  | xargs -n 2 -P 25  bash /mnt/data2/dem_variables/GMTED2010/scripts/sc2_class_treshold_percent.sh 
10
#  for file in /mnt/data2/dem_variables/GMTED2010/tiles/mx75_grd_tif/*.tif ; do echo $file mx ; done  | xargs -n 2 -P 25  bash /mnt/data2/dem_variables/GMTED2010/scripts/sc2_class_treshold_percent.sh 
11

  
12
# run the script in the  @bulldogj 
13

  
14
# rm /lustre0/scratch/ga254/stderr/* ; rm /lustre0/scratch/ga254/stdout/* ; 
15

  
16
# for file in /home2/ga254/scratch/dem_bj/GMTED2010/tiles/mi75_grd_tif/*.tif  ; do qsub -v file=$file,mm=mi   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2_class_treshold_percent_bj.sh  ; done 
17

  
18
# for file in /home2/ga254/scratch/dem_bj/GMTED2010/tiles/md75_grd_tif/*.tif  ; do qsub -v file=$file,mm=md   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2_class_treshold_percent_bj.sh  ; done 
19

  
20
# for file in /home2/ga254/scratch/dem_bj/GMTED2010/tiles/mx75_grd_tif/*.tif  ; do qsub -v file=$file,mm=mx   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2_class_treshold_percent_bj.sh  ; done 
21

  
22
# to check 
23
# ny=45 ; for n in `seq 1 9` ;do echo `gdallocationinfo -valonly altitude/class/5_1_class_tmp3.tif 2$n $ny` `gdallocationinfo  -valonly  tiles/mn75_grd_tif/5_1.tif 2$n $ny` ; done 
24

  
25
#PBS -S /bin/bash 
26
#PBS -q fas_normal
27
#PBS -l mem=4gb
28
#PBS -l walltime=10:00:00
29
#PBS -l nodes=10:ppn=4
30
#PBS -V
31
#PBS -o /lustre0/scratch/ga254/stdout 
32
#PBS -e /lustre0/scratch/ga254/stderr
33

  
34
# load moduels 
35

  
36
module load Tools/Python/2.7.3
37
module load Libraries/GDAL/1.10.0
38
module load Tools/PKTOOLS/2.4.2
39
module load Libraries/OSGEO/1.10.0
40

  
41
# file=$1    
42
# mm=$2     
43

  
44
file=${file}  
45
mm=${mm}
46

  
47
filename=$(basename $file .tif)
48

  
49
echo $file
50
echo $mm
51

  
52
INDIR=/home2/ga254/scratch/dem_bj/GMTED2010/tiles/$mm"75_grd_tif"
53
OUTDIR=/home2/ga254/scratch/dem_bj/GMTED2010/altitude/class_$mm/class
54

  
55
echo  calcualte altitude  every 100 meter  using the the Int16 factors for $file 
56

  
57
time (
58

  
59
gdal_calc.py -A  $INDIR/$filename.tif   --calc="(A / 100)"  --outfile=$OUTDIR/../tmp/$filename"_class_tmp1.tif" --type=Int16 --overwrite --co=COMPRESS=LZW 
60
gdal_calc.py -A  $OUTDIR/../tmp/$filename"_class_tmp1.tif" --calc="(A * 100)" --outfile=$OUTDIR/../tmp/$filename"_class_tmp2.tif" --type=Int16 --overwrite --co=COMPRESS=LZW 
61

  
62

  
63
rm $OUTDIR/../tmp/$filename"_class_tmp1.tif" 
64

  
65
gdal_translate -co COMPRESS=LZW -co ZLEVEL=9  $OUTDIR/../tmp/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class.tif"
66
rm $OUTDIR/../tmp/$filename"_class_tmp2.tif"
67

  
68

  
69
gdalinfo -mm $OUTDIR/$filename"_class.tif"  | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
70

  
71
echo min and max for $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
72

  
73
# start to calculate for each treshold percent pixel
74
 
75
for class in $(seq `awk '{ print $1}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt` 100    `awk '{ print $2}' $OUTDIR/../tmp/${filename}_min_max_${mm}.txt` ) ; do 
76

  
77
    class_start=$class
78
    class_end=$(awk '{ print $2}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt)
79
    class_string=$(for class_unique in $(seq $class_start 100  $class_end  ) ; do echo -n "-class $class_unique "  ; done) 
80

  
81
    echo applaid the filter for the classes  $class_string
82

  
83
    pkfilter -dx 4 -dy 4 $class_string -f density -d 4 -i $OUTDIR/$filename"_class.tif" -o $OUTDIR/../class$class/$filename"_C"$class"Perc.tif" -co COMPRESS=LZW -co ZLEVEL=9 -ot Byte 
84

  
85
done 
86

  
87
)
terrain/procedures/dem_variables/gmted2010_res_x10/sc5b_dem_variables_bj.sh
1
# variables derived from the dem following commands in http://www.gdal.org/gdaldem.html # gdaldem_slope 
2
# to check ls *.tif  | xargs -n 1 -P 30 bash -c $' gdalinfo  -mm $1 |grep Max  | awk \'{ gsub("[=,]", " ") ;  print $3,$4  }\'  ' _ 
3

  
4
# find /mnt/data2/dem_variables/GMTED2010/{aspect,roughness,slope,tpi,tri}  -name *.tif | xargs -n 1 -P 10 rm ; 
5

  
6

  
7
# rm    /lustre0/scratch/ga254/stderr/*  ; rm    /lustre0/scratch/ga254/stdout/*
8

  
9
# for file in `ls /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/md75_grd_tif/?_?.tif` ; do qsub  -v file=$file  /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc5b_dem_variables_bj.sh ; done 
10

  
11
# for file in `ls /lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/md75_grd_tif/?_?.tif` ; do bash  /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc5b_dem_variables_bj.sh $file   ; done 
12
# file=$1   
13

  
14
#PBS -S /bin/bash 
15
#PBS -q fas_normal
16
#PBS -l mem=4gb
17
#PBS -l walltime=5:00:00 
18
#PBS -l nodes=1:ppn=4
19
#PBS -V
20
#PBS -o /lustre0/scratch/ga254/stdout 
21
#PBS -e /lustre0/scratch/ga254/stderr
22

  
23

  
24
# load moduels 
25

  
26
module load Tools/Python/2.7.3
27
module load Libraries/GDAL/1.10.0
28
module load Tools/PKTOOLS/2.4.2
29
module load Libraries/OSGEO/1.10.0
30

  
31

  
32

  
33

  
34
file=${file}
35

  
36
INDIR_MI=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/mi75_grd_tif
37
INDIR_MD=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/md75_grd_tif
38
INDIR_MX=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/mx75_grd_tif
39
INDIR_MN=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles/mn75_grd_tif
40
TMP=/tmp
41

  
42
export OUTDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
43

  
44
export filename=`basename $file .tif`
45

  
46
time ( 
47
# 30 min for this 
48
echo max of the max with file    $INDIR_MX/$filename.tif 
49
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f max -d 4 -i $INDIR_MX/$filename.tif  -o $OUTDIR/altitude/max_of_mx/tiles/${filename}.tif  -co COMPRESS=LZW -ot Int16  
50

  
51

  
52
echo max of the max with file    $INDIR_MI/$filename.tif 
53
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f min  -d 4 -i $INDIR_MI/$filename.tif -o $OUTDIR/altitude/min_of_mi/tiles/${filename}.tif  -co COMPRESS=LZW -ot Int16  
54

  
55
echo mean of the mn with file    $INDIR_MN/$filename.tif 
56
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f mean  -d 4 -i $INDIR_MN/$filename.tif -o $OUTDIR/altitude/mean_of_mn/tiles/${filename}.tif  -co COMPRESS=LZW -ot Int16  
57

  
58
echo meadian of the md with file  $INDIR_MD/$filename.tif 
59
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f median  -d 4 -i $INDIR_MD/$filename.tif -o $OUTDIR/altitude/median_of_md/tiles/${filename}.tif  -co COMPRESS=LZW -ot Int16  
60

  
61
echo stdev of mn with file $INDIR_MN/$filename.tif 
62

  
63
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f var -d 4 -i $INDIR_MN/$filename.tif  -co COMPRESS=LZW  -o  $TMP/tmp_${filename}.tif  -ot Int32   # max 1552385.000 sqrt(1245.947)
64
gdal_calc.py  --co=COMPRESS=LZW    -A  $TMP/tmp_${filename}.tif   --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/altitude/stdev_of_mn/tiles/${filename}.tif
65
rm -f $TMP/tmp_${filename}.tif 
66

  
67
echo stdev of md with file $INDIR_MD/$filename.tif 
68

  
69
/home2/ga254/bin/bin/pkfilter -m -32768 -dx 4 -dy 4   -f var -d 4 -i $INDIR_MD/$filename.tif  -co COMPRESS=LZW  -o  $TMP/tmp_${filename}.tif  -ot Int32   # max 1552385.000 sqrt(1245.947)
70
gdal_calc.py  --co=COMPRESS=LZW -A  $TMP/tmp_${filename}.tif   --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/altitude/stdev_of_md/tiles/${filename}.tif
71
rm -f $TMP/tmp_${filename}.tif 
72

  
73

  
74

  
75
# form here only md will be used
76

  
77
INDIR=$INDIR_MD
78
mm=md
79

  
80
# starting to use gdaldem to compute variables. Gdaldem use -9999 as no data. 
81

  
82
echo  slope with file   $INDIR/$filename.tif
83
gdaldem slope  -s 111120 -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/slope/tiles/${filename}_${mm}.tif  # -s to consider xy in degree and z in meters
84
# slope median 
85
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median  -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o $OUTDIR/slope/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Byte
86
# slope stdev 
87
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW  -o $TMP/tmp_${filename}_${mm}.tif  -ot Int32
88
gdal_calc.py  --co=COMPRESS=LZW -A  $TMP/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/slope/stdev/tiles/${filename}_${mm}.tif
89
rm -f $TMP/tmp_${filename}_${mm}.tif
90
# slope min 
91
/home2/ga254/bin/bin/pkfilter -m -9999  -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
92
# slope max
93
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
94
# slope mean
95
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -ot Byte 
96

  
97
# rm -f  $OUTDIR/slope/tiles/$filename.tif
98

  
99
echo  generate a Terrain Ruggedness Index TRI  with file   $file
100
gdaldem TRI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tri/tiles/${filename}_${mm}.tif
101
# tri median 
102
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o $OUTDIR/tri/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
103
# tri stdev 
104
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4    -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -o  $TMP/tmp_${filename}_${mm}.tif
105
gdal_calc.py  --co=COMPRESS=LZW -A  $TMP/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/tri/stdev/tiles/${filename}_${mm}.tif
106
rm -f  $TMP/tmp_${filename}_${mm}.tif
107
# tri min 
108
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16  
109
# tri max
110
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
111
# tri mean
112
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
113

  
114
# rm -f  $OUTDIR/tri/tiles/$filename.tif
115

  
116
echo  generate a Topographic Position Index TPI  with file   $INDIR/$filename.tif
117

  
118
gdaldem TPI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tpi/tiles/${filename}_${mm}.tif      # tpi has negative number 
119

  
120
/home2/ga254/bin/oft-calc -ot Float32   $OUTDIR/tri/tiles/${filename}_${mm}.tif $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"    &> /dev/null   <<EOF
121
1
122
#1 10 *
123
EOF
124

  
125
# tpi median 
126
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o $OUTDIR/tpi/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
127
echo tpi stdev 
128
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -co COMPRESS=LZW    -o $TMP/tmp_${filename}_${mm}.tif 
129
gdal_calc.py  --co=COMPRESS=LZW -A  $TMP/tmp_${filename}_${mm}.tif  --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/tpi/stdev/tiles/${filename}_${mm}.tif
130
rm -f  $TMP/tmp_${filename}_${mm}.tif
131
# tpi min 
132
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/min/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
133
# tpi max
134
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/max/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
135
# tpi mean
136
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
137

  
138

  
139
echo  generate roughness   with file   $INDIR/$filename.tif
140

  
141
gdaldem  roughness  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/roughness/tiles/${filename}_${mm}.tif
142

  
143
# roughness median 
144
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
145
echo roughness stdev 
146
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var  -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -o $TMP/tmp_${filename}_${mm}.tif  
147
gdal_calc.py  --co=COMPRESS=LZW -A  $TMP/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/roughness/stdev/tiles/${filename}_${mm}.tif
148
rm -f  $TMP/tmp_${filename}_${mm}.tif
149
# roughness min 
150
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
151
# roughness max
152
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
153
# roughness mean
154
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
155

  
156
# rm -f   $OUTDIR/roughness/tiles/${filename}_${mm}.tif
157

  
158

  
159
echo  aspect  with file   $INDIR/$filename.tif
160

  
161
gdaldem aspect  -zero_for_flat -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/aspect/tiles/${filename}_${mm}.tif
162

  
163
# r1 aspect , r2 slope 
164

  
165
gdal_calc.py  --co=COMPRESS=LZW --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(sin(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" --overwrite --type Float32
166
gdal_calc.py  --co=COMPRESS=LZW --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(cos(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" --overwrite --type Float32
167

  
168
gdal_calc.py  --co=COMPRESS=LZW --NoDataValue -9999 -A $OUTDIR/slope/tiles/${filename}_${mm}.tif -B  $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif"  --calc="((sin(A))*B)" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" --overwrite --type Float32
169
gdal_calc.py  --co=COMPRESS=LZW --NoDataValue -9999 -A $OUTDIR/slope/tiles/${filename}_${mm}.tif -B  $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif"  --calc="((sin(A))*B)" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" --overwrite --type Float32
170

  
171
echo  aspect sin   cos  Ew  Nw   median 
172
# sin
173
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
174
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_f.tif"  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null    <<EOF
175
1
176
#1 10000 *
177
EOF
178
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_t10k.tif"  
179
rm  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" 
180
# cos
181
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
182
/home2/ga254/bin/oft-calc  -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_f.tif"  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
183
1
184
#1 10000 *
185
EOF
186
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_t10k.tif" 
187
rm  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" 
188
# Ew
189
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
190
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_f.tif"  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null   <<EOF
191
1
192
#1 10000 *
193
EOF
194
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_t10k.tif" 
195
rm  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" 
196
# Nw
197
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
198
/home2/ga254/bin/oft-calc  -ot Int16  $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_f.tif"  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
199
1
200
#1 10000 *
201
EOF
202
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_t10k.tif" 
203
rm  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" 
204

  
205

  
206
echo aspect sin   cos  Ew  Nw   mean
207
# sin
208
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
209
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_f.tif"  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" &> /dev/null  <<EOF
210
1
211
#1 10000 *
212
EOF
213
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_t10k.tif"  
214
rm  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" 
215
# cos
216
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
217
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_f.tif"  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
218
1
219
#1 10000 *
220
EOF
221
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_t10k.tif" 
222
rm  $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" 
223
# Ew
224
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
225
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_f.tif"  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null  <<EOF
226
1
227
#1 10000 *
228
EOF
229
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_t10k.tif" 
230
rm  $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" 
231
# Nw
232
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
233
/home2/ga254/bin/oft-calc  -ot Int16  $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_f.tif"  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
234
1
235
#1 10000 *
236
EOF
237
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
238
1
239
#1 10000 *
240
EOF
241
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_t10k.tif" 
242
rm  $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" 
243

  
244
echo aspect sin   cos  Ew  Nw   max
245
# sin
246
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
247
/home2/ga254/bin/oft-calc -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_f.tif"  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif"   &> /dev/null  <<EOF
248
1
249
#1 10000 *
250
EOF
251
gdal_translate  -co COMPRESS=LZW  -ot Int16 $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_t10k.tif"  
252
rm  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" 
253
# cos
254
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
255
/home2/ga254/bin/oft-calc  -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_f.tif"   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
256
1
257
#1 10000 *
258
EOF
259
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_t10k.tif" 
260
rm   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" 
261
# Ew
262
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
263
/home2/ga254/bin/oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_f.tif"   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
264
1
265
#1 10000 *
266
EOF
267
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_t10k.tif" 
268
rm   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" 
269
# Nw
270
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
271
/home2/ga254/bin/oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_f.tif"   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
272
1
273
#1 10000 *
274
EOF
275
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_t10k.tif" 
276
rm   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" 
277

  
278
echo aspect sin   cos  Ew  Nw   min 
279
# sin
280
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
281
/home2/ga254/bin/oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_f.tif"   $TMP/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null   <<EOF
282
1
283
#1 10000 *
284
EOF
285
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_t10k.tif"  
286
rm   $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" 
287
# cos
288
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
289
/home2/ga254/bin/oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_f.tif"   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
290
1
291
#1 10000 *
292
EOF
293
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_t10k.tif" 
294
rm   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" 
295
# Ew
296
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
297
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_f.tif"   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
298
1
299
#1 10000 *
300
EOF
301
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_t10k.tif" 
302
rm   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" 
303
# Nw
304
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
305
/home2/ga254/bin/oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_f.tif"   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
306
1
307
#1 10000 *
308
EOF
309
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_t10k.tif" 
310
rm   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" 
311

  
312
echo aspect sin   cos  Ew  Nw   stdev
313
# stdev   
314
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
315
gdal_calc.py  --co=COMPRESS=LZW -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   $TMP/${filename}_${mm}"_sin_t10k_tmp.tif"
316
gdal_translate  -co COMPRESS=LZW  -ot Int16  $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_t10k.tif"  
317
rm   $TMP/${filename}_${mm}"_sin_t10k_tmp.tif" 
318
# cos
319
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
320
gdal_calc.py  --co=COMPRESS=LZW -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif"
321
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_t10k.tif" 
322
rm   $TMP/${filename}_${mm}"_cos_t10k_tmp.tif" 
323
# Ew
324
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
325
gdal_calc.py  --co=COMPRESS=LZW -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif"
326
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_t10k.tif" 
327
rm   $TMP/${filename}_${mm}"_Ew_t10k_tmp.tif" 
328
# Nw
329
/home2/ga254/bin/bin/pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
330
gdal_calc.py  --co=COMPRESS=LZW -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif"
331
gdal_translate  -co COMPRESS=LZW  -ot Int16   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_t10k.tif" 
332
rm   $TMP/${filename}_${mm}"_Nw_t10k_tmp.tif" 
333

  
334
# Look for lines such as "Max Util Resources Per Task" in the output file from your job.  
335

  
336

  
337
)
338

  
339
checkjob -v $PBS_JOBID 
terrain/procedures/dem_variables/gmted2010_res_x10/sc6a_class_treshold_density_merge_bj.sh
1

  
2
# perform a merging action for the /mnt/data2/dem_variables/GMTED2010/altitude/class_mi and /mnt/data2/dem_variables/GMTED2010/altitude/class_mx
3
# create in avery clever way missing tiles. The missing tiles were appear if all the pixel where above or below a treshold, therfore all 100% or 0%
4

  
5
# for dir in `seq -500 100 8600` ; do echo $dir mi ; done |  xargs -n 2 -P 20 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
6

  
7
# for dir in `seq -500 100 8700` ; do echo $dir mx ; done |  xargs -n 2 -P 20 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
8

  
9

  
10

  
11
# run the script in the  @bulldogj 
12

  
13
# rm /lustre0/scratch/ga254/stderr/* ; rm /lustre0/scratch/ga254/stdout/* ; 
14

  
15
# create tif with value 0 or 100 used to refeel the area
16

  
17
# xargs controllare il risultato di qeusta linea sotto. 
18

  
19
#    ls  /home2/ga254/scratch/dem_bj/GMTED2010/tiles/md75_grd_tif/*.tif | xargs -n 1 -P 100 bash -c $' file=$1   ;   filename=`basename $file .tif` ;  pkgetmask -min 10000 -max 10001  -t 0 -ot Byte -i $file -co COMPRESS=LZW -co ZLEVEL=9 -o /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value0/$filename.tif  ;   gdalwarp -tr 0.008333333333333 0.008333333333333  -co COMPRESS=LZW -co ZLEVEL=9  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value0/tmp_$filename.tif  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value0/$filename.tif;   pkgetmask -min 10000 -max 10001 -t 0 -f 100  -ot Byte -i $file -co COMPRESS=LZW -co ZLEVEL=9 -o /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value100/tmp_$filename.tif ;  gdalwarp -tr 0.008333333333333 0.008333333333333  -co COMPRESS=LZW -co ZLEVEL=9  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value100/tmp_$filename.tif  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value100/$filename.tif ; rm /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value100/tmp_$filename.tif             ' _ 
20

  
21

  
22
# to que after the completition of sc2 
23

  
24
# n=`qstat | grep percent_bj | wc -l` ; for time in `seq 1 100` ; do if [ $n  -eq 0  ] ; then  echo run the script ;   ; exit   ; else  sleep 60   ;   echo sleeping   ;  fi ; done
25

  
26
# for dir in `seq -400 100 8600` ; do  qsub -v dir=$dir,mm=mi   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge_bj.sh ; done # 400 8600 range confirrmed  (-500 tutti i valore == 100)
27
# for dir in `seq -500 100 8700` ; do  qsub -v dir=$dir,mm=md   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge_bj.sh ; done # -500 8700 range confirrmed 
28
# for dir in `seq -500 100 8700` ; do  qsub -v dir=$dir,mm=mx   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge_bj.sh ; done # -500 8700 range confirrmed
29

  
30

  
31
#PBS -S /bin/bash 
32
#PBS -q fas_normal
33
#PBS -l mem=4gb
34
#PBS -l walltime=2:00:00 # portato a 2 ore perche a 1 ora veniva bloccato.
35
#PBS -l nodes=1:ppn=4
36
#PBS -V
37
#PBS -o /lustre0/scratch/ga254/stdout 
38
#PBS -e /lustre0/scratch/ga254/stderr
39

  
40

  
41
# load moduels 
42

  
43
module load Tools/Python/2.7.3
44
module load Libraries/GDAL/1.10.0
45
module load Tools/PKTOOLS/2.4.2
46
module load Libraries/OSGEO/1.10.0
47

  
48
#  DIR=$1
49
#  mm=$2
50

  
51
DIR=${dir}
52
mm=${mm}
53
INDIR=/home2/ga254/scratch/dem_bj/GMTED2010/altitude/class_${mm}/class${DIR}          # this has pixel value = 0.002083333333333
54
INDIR_C=/home2/ga254/scratch/dem_bj/GMTED2010/altitude/class_${mm}/class              # this has pixel value = 0.002083333333333
55
INDIR_Cm100=/home2/ga254/scratch/dem_bj/GMTED2010/altitude/class_${mm}/class-100      # this has pixel value = 0.008333333333333 this is the only class with all (50) tiles
56
OUTDIR=/home2/ga254/scratch/dem_bj/GMTED2010/altitude/percent_class_${mm}
57
TMP=/home2/ga254/scratch/dem_bj/GMTED2010/tmp
58

  
59

  
60
rm  -f $OUTDIR/file_processed_sc3.txt  # the file has ben processed by the script sc1_dem_treshold_percent.sh
61

  
62
for file  in `ls $INDIR_C/*.tif`  ; do 
63
    tile=`basename $file _class.tif`
64

  
65
    if [ -f $INDIR/$tile"_C"$DIR"Perc.tif" ] ; then 
66
	echo the file  $INDIR/$tile"_C"$DIR"Perc.tif"   exist and will be merged as it is
67
	echo $tile"_C"$DIR"Perc.tif" >>  $OUTDIR/file_processed_sc3.txt # usefull to list file processed by script sc1, in case of delation use this.
68
    else
69

  
70
gdalinfo -mm    $INDIR_C/$tile"_class.tif" | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > $TMP/${tile}_class${DIR}_min_max_${mm}.txt 
71

  
72
min=`awk '{ print $1}'  $TMP/${tile}_class${DIR}_min_max_${mm}.txt `  
73
max=`awk '{ print $2}'  $TMP/${tile}_class${DIR}_min_max_${mm}.txt `
74
rm -f  $TMP/${tile}_class${DIR}_min_max_${mm}.txt 
75

  
76
echo $min and $max compare to $DIR
77

  
78
if [ $max -lt $DIR ]  ;  then 
79
      echo copy the $INDIR/$tile"_C"$DIR"Perc.tif"  with 0 value
80
      echo $INDIR/$tile"_C"$DIR"Perc.tif" with 0 value >>  $INDIR/refill_file_list.txt
81
      # pkgetmask -min 10000 -max 10001  -t 0 -ot Byte -i  $INDIR_Cm100/$tile"_C-100Perc.tif" -co COMPRESS=LZW  -o $INDIR/$tile"_C"$DIR"Perc.tif" 
82
      # change the previus line with this to avoid constant calculation 
83
      cp  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value0/$tile".tif"     $INDIR/$tile"_C"$DIR"Perc.tif"  
84
      
85
fi 
86

  
87
if [ $min -gt $DIR ] ; then 
88
      echo copy the $INDIR/$tile"_C"$DIR"Perc.tif"  with 100 value 
89
      echo $INDIR/$tile"_C"$DIR"Perc.tif" with 100 value >>  $INDIR/refill_file_list.txt
90
      # pkgetmask -min 10000 -max 10001  -t 0 -f 100  -ot Byte  -co COMPRESS=LZW  -i $INDIR_Cm100/$tile"_C-100Perc.tif"  -o $INDIR/$tile"_C"$DIR"Perc.tif" 
91
      cp  /home2/ga254/scratch/dem_bj/GMTED2010/altitude/value100/$tile".tif"    $INDIR/$tile"_C"$DIR"Perc.tif"  
92
      
93
fi 
94

  
95
fi  
96

  
97
done
98

  
99
echo STARTING THE MERGING ACTION 
100
rm -f $OUTDIR/perc_$DIR.tif
101
gdal_merge.py   -co COMPRESS=LZW    -ot Byte -o $OUTDIR/perc_$DIR.tif  $INDIR/*.tif 
102

  
103
if [ -f $OUTDIR/color-bw.txt ] ; then 
104
    echo the $OUTDIR/color-bw.txt exist ;
105
else 
106
    pkcreatect -g -min 0 -max 100 | sort -k 1,1 -rg | awk '{  print NR-1 , $2 ,$3 ,$4 ,$5 }'  >  $OUTDIR/color-bw.txt
107
fi 
108

  
109
pkcreatect -ct  $OUTDIR/color-bw.txt -co COMPRESS=LZW -co INTERLEAVE=BAND  -d "Percent of elevation values >= ${DIR}m" -i  $OUTDIR/perc_$DIR.tif -o  $OUTDIR/threshold_${DIR}_GMTED2010_${mm}.tif   
110

  
111
rm $OUTDIR/perc_$DIR.tif
terrain/procedures/dem_variables/gmted2010_res_x10/sc6b_dem_variables_merge_bj.sh
1
# calculate different variables for the dem 
2

  
3
#  rm    /lustre0/scratch/ga254/stderr/*  ; rm    /lustre0/scratch/ga254/stdout/* 
4

  
5
# for dir1  in slope tri tpi roughness aspect ; do for dir2 in max mean median min stdev; do  qsub  -v DIR=$dir1/$dir2,mm=md  /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc6b_dem_variables_merge_bj.sh ; done ; done 
6

  
7
# for dir1 in tri  ; do for dir2 in max ; do  bash  /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc6b_dem_variables_merge_bj.sh  $dir1/$dir2 md  ; done ; done 
8

  
9
# for dir1  in altitude ; do for dir2 in max_of_mx  mean_of_mn median_of_md min_of_mi stdev_of_md stdev_of_mn; do  qsub  -v DIR=$dir1/$dir2,mm=md  /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc6b_dem_variables_merge_bj.sh ; done ; done 
10

  
11
# for dir1  in altitude ; do for dir2 in max_of_mx  mean_of_mn median_of_md min_of_mi stdev_of_md stdev_of_mn; do  bash   /lustre0/scratch/ga254/scripts_bj_bk/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc6b_dem_variables_merge_bj.sh   $dir1/$dir2 md  ; done ; done 
12

  
13
#PBS -S /bin/bash 
14
#PBS -q fas_normal
15
#PBS -l mem=10gb
16
#PBS -l walltime=4:00:00 
17
#PBS -l nodes=1:ppn=4
18
#PBS -V
19
#PBS -o /lustre0/scratch/ga254/stdout 
20
#PBS -e /lustre0/scratch/ga254/stderr
21

  
22
# load moduels 
23

  
24
module load Tools/Python/2.7.3
25
module load Libraries/GDAL/1.10.0
26
module load Tools/PKTOOLS/2.4.2
27
module load Libraries/OSGEO/1.10.0
28

  
29
time (
30
export OUTDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010
31

  
32
# export DIR=$1
33
# export mm=$2
34

  
35
export DIR=$DIR
36
export mm=md
37

  
38
export dir1=$(echo ${DIR%/*})   # cancel the part after  /
39
export dir2=$(echo ${DIR#*/})   # cancel the part before /
40

  
41

  
42
if [ $dir1 = altitude ]  ; then type=Int16 ; fi 
43
if [ $dir1 = aspect ]    ; then type=Int16 ; fi  
44
if [ $dir1 = slope ]     ; then type=Byte  ; fi  
45
if [ $dir1 = tri ]       ; then type=Int16 ; fi 
46
if [ $dir1 = tpi ]       ; then type=Int16 ; fi   
47
if [ $dir1 = roughness ] ; then type=Int16 ; fi 
48

  
49
if [ $dir1 != aspect ]; then 
50

  
51
echo processing merging tiles in $dir1  $dir2  
52
         
53
rm -f $OUTDIR/$DIR/$dir1"_"$dir2.tif
54
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  
55
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  
56
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  
57
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif
58
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif
59

  
60

  
61
if [ $dir1 = altitude ]  ; then
62

  
63
echo clipping tiles in $dir1  $dir2   $OUTDIR/$DIR/tiles/[0-1]_?.tif 
64

  
65
echo left tiles center 
66
ls $OUTDIR/$DIR/tiles/0_[1-3].tif | xargs -n 1  -P 3  bash -c $' 
67
file=$1 ; filename=`basename $file`  ;  xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3360 
68
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
69
' _ 
70

  
71
echo right tiles center 
72
ls $OUTDIR/$DIR/tiles/9_[1-3].tif | xargs -n 1  -P 3  bash -c $' 
73
file=$1 ; filename=`basename $file` ; xoff=2 ; yoff=2 ;  xsize=4322 ; ysize=3360 ; 
74
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
75
' _ 
76

  
77
echo top tiles center  
78
ls $OUTDIR/$DIR/tiles/[1-8]_0.tif  | xargs -n 1  -P 8  bash -c $'
79
file=$1 ; filename=`basename $file` ;  xoff=2 ; yoff=0 ;  xsize=4320 ; ysize=3362 
80
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
81
' _ 
82

  
83
echo botton  tiles center  
84
ls  $OUTDIR/$DIR/tiles/[1-8]_4.tif  | xargs -n 1  -P 8  bash -c $'
85
file=$1 ; filename=`basename $file` ; xoff=2 ; yoff=2 ;  xsize=4320 ; ysize=3362 
86
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
87
' _ 
88

  
89
echo top left 
90
file=$OUTDIR/$DIR/tiles/0_0.tif ; filename=`basename $file` ; xoff=0 ; yoff=0 ; xsize=4322 ; ysize=3362 
91
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
92

  
93
echo top right 
94
file=$OUTDIR/$DIR/tiles/9_0.tif ; filename=`basename $file` ; xoff=2 ; yoff=0 ; xsize=4322 ; ysize=3362 
95
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
96

  
97
echo botton left 
98
file=$OUTDIR/$DIR/tiles/0_4.tif ; filename=`basename $file` ; xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3362 
99
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
100

  
101
echo botton  right 
102
file=$OUTDIR/$DIR/tiles/9_4.tif ; filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4322 ; ysize=3362 
103
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
104

  
105
echo central immage 
106
ls  $OUTDIR/$DIR/tiles/[1-8]_[1-3].tif  | xargs -n 1  -P 8  bash -c $'
107
file=$1 ; filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4320 ; ysize=3360 
108
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
109

  
110
' _ 
111

  
112

  
113
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[0-1]_?.tif
114
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[2-3]_?.tif
115
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[4-5]_?.tif
116
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[6-7]_?.tif
117
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[8-9]_?.tif
118

  
119
else
120

  
121
echo  left tiles center 
122
ls $OUTDIR/$DIR/tiles/0_[1-3]_${mm}.tif | xargs -n 1  -P 3  bash -c $' 
123
file=$1  ; filename=`basename $file` ;  xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3360 
124
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
125
' _ 
126

  
127
echo  right tiles center 
128
ls $OUTDIR/$DIR/tiles/9_[1-3]_${mm}.tif | xargs -n 1  -P 3  bash -c $' 
129
file=$1 ;filename=`basename $file` ;  xoff=2 ; yoff=2 ;  xsize=4322 ; ysize=3360 ; 
130
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
131
' _ 
132

  
133
echo top tiles center  
134
ls $OUTDIR/$DIR/tiles/[1-8]_0_${mm}.tif  | xargs -n 1  -P 8  bash -c $'
135
file=$1 ;filename=`basename $file` ; xoff=2 ; yoff=0 ;  xsize=4320 ; ysize=3362 
136
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
137
' _ 
138

  
139
echo  botton  tiles center  
140
ls  $OUTDIR/$DIR/tiles/[1-8]_4_${mm}.tif  | xargs -n 1  -P 8  bash -c $'
141
file=$1 ;filename=`basename $file` ;  xoff=2 ; yoff=2 ;  xsize=4320 ; ysize=3362 
142
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
143
' _ 
144

  
145
echo  top left 
146
file=$OUTDIR/$DIR/tiles/0_0_${mm}.tif ; filename=`basename $file` ; xoff=0 ; yoff=0 ; xsize=4322 ; ysize=3362 
147
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
148

  
149
echo  top right 
150
file=$OUTDIR/$DIR/tiles/9_0_${mm}.tif ;filename=`basename $file` ; xoff=2 ; yoff=0 ; xsize=4322 ; ysize=3362 
151
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
152

  
153
echo  botton left 
154
file=$OUTDIR/$DIR/tiles/0_4_${mm}.tif ;filename=`basename $file` ; xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3362 
155
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
156

  
157
echo  botton  right 
158
file=$OUTDIR/$DIR/tiles/9_4_${mm}.tif ;filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4322 ; ysize=3362 
159
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
160

  
161
echo central immage 
162
ls  $OUTDIR/$DIR/tiles/[1-8]_[1-3]_${mm}.tif  | xargs -n 1  -P 8  bash -c $'
163
file=$1 ; filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4320 ; ysize=3360 
164
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
165

  
166
' _ 
167

  
168

  
169
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[0-1]_?_${mm}.tif
170
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[2-3]_?_${mm}.tif
171
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[4-5]_?_${mm}.tif
172
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[6-7]_?_${mm}.tif
173
    /home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[8-9]_?_${mm}.tif
174

  
175
fi
176

  
177
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2.tif
178

  
179
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif   $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif 
180

  
181
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a".tif  
182
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b".tif  
183
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c".tif  
184
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d".tif
185
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e".tif
186

  
187
gdal_translate -co COMPRESS=LZW  -co ZLEVEL=9 $OUTDIR/$DIR/$dir1"_"$dir2.tif $OUTDIR/$DIR/${dir1}_${dir2}_${mm}.tif
188
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2.tif  
189

  
190
else  # just applaied to the aspect variables 
191

  
192
echo processing merging tiles for the different aspect variables in $dir1   
193

  
194
for aspect_var in "_sin_t10k" "_cos_t10k" "_Ew_t10k" "_Nw_t10k" ; do 
195

  
196
# left tiles center 
197
ls $OUTDIR/$DIR/tiles/0_[1-3]_${mm}$aspect_var.tif | xargs -n 1  -P 3  bash -c $' 
198
file=$1  ; filename=`basename $file` ;  xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3360 
199
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
200
' _ 
201

  
202
# right tiles center 
203
ls $OUTDIR/$DIR/tiles/9_[1-3]_${mm}$aspect_var.tif | xargs -n 1  -P 3  bash -c $' 
204
file=$1 ;filename=`basename $file` ; xoff=2 ; yoff=2 ;  xsize=4322 ; ysize=3360 ; 
205
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
206
' _ 
207

  
208
# top tiles center  
209
ls $OUTDIR/$DIR/tiles/[1-8]_0_${mm}$aspect_var.tif  | xargs -n 1  -P 8  bash -c $'
210
file=$1 ;filename=`basename $file` ; xoff=2 ; yoff=0 ;  xsize=4320 ; ysize=3362 
211
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
212
' _ 
213

  
214
# botton  tiles center  
215
ls  $OUTDIR/$DIR/tiles/[1-8]_4_${mm}$aspect_var.tif  | xargs -n 1  -P 8  bash -c $'
216
file=$1 ;filename=`basename $file` ; xoff=2 ; yoff=2 ;  xsize=4320 ; ysize=3362
217
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
218
' _ 
219

  
220
# top left 
221
file=$OUTDIR/$DIR/tiles/0_0_${mm}$aspect_var.tif ;filename=`basename $file` ; xoff=0 ; yoff=0 ; xsize=4322 ; ysize=3362 
222
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
223

  
224
# top right 
225
file=$OUTDIR/$DIR/tiles/9_0_${mm}$aspect_var.tif ;filename=`basename $file` ; xoff=2 ; yoff=0 ; xsize=4322 ; ysize=3362 
226
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
227

  
228
# botton left 
229
file=$OUTDIR/$DIR/tiles/0_4_${mm}$aspect_var.tif ;filename=`basename $file` ; xoff=0 ; yoff=2 ; xsize=4322 ; ysize=3362 
230
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
231

  
232
# botton  right 
233
file=$OUTDIR/$DIR/tiles/9_4_${mm}$aspect_var.tif ;filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4322 ; ysize=3362 
234
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
235

  
236
# central immage 
237
ls  $OUTDIR/$DIR/tiles/[1-8]_[1-3]_${mm}$aspect_var.tif  | xargs -n 1  -P 8  bash -c $'
238
file=$1 ; filename=`basename $file` ; xoff=2 ; yoff=2 ; xsize=4320 ; ysize=3360 
239
gdal_translate -co ZLEVEL=9 -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $file $OUTDIR/$DIR/tiles/clip$filename
240

  
241
' _ 
242

  
243

  
244
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif
245
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif
246
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif
247
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif
248
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
249

  
250
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[0-1]_?_${mm}$aspect_var.tif
251
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[2-3]_?_${mm}$aspect_var.tif 
252
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[4-5]_?_${mm}$aspect_var.tif
253
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[6-7]_?_${mm}$aspect_var.tif
254
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif -ot $type -co COMPRESS=LZW  $OUTDIR/$DIR/tiles/clip[8-9]_?_${mm}$aspect_var.tif
255

  
256
rm -f  $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif
257

  
258
/home2/ga254/bin/gdal_merge_bylines.py -o $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif -ot $type -co COMPRESS=LZW   $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif  $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif   $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
259

  
260
gdal_translate -co COMPRESS=LZW  -co ZLEVEL=9  $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif $OUTDIR/$DIR/${dir1}_${dir2}_${mm}_${aspect_var}.tif
261
rm -f $OUTDIR/$DIR/$dir1"_"$dir2$aspect_var.tif
262

  
263
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_a"$aspect_var.tif
264
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_b"$aspect_var.tif  
265
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_c"$aspect_var.tif  
266
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_d"$aspect_var.tif
267
rm -f $OUTDIR/$DIR/$dir1"_"$dir2"_e"$aspect_var.tif
268

  
269
done
270

  
271
fi 
272

  
273
) 
274

  
275
checkjob -v $PBS_JOBID
276

  
277

  
278

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff