Project

General

Profile

« Previous | Next » 

Revision 0fe072a4

Added by selv in ga254@bulldogj almost 11 years ago

manly change for solar radiation

View differences:

terrain/procedures/dem_variables/GFC2013/#sc2_merge_lossyear.sh#
1

  
2
# for YEAR in `seq 1 12`  ; do qsub -v  YEAR=$YEAR /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/GFC2013/sc2_merge_lossyear.sh  ; done 
3

  
4
#PBS -S /bin/bash 
5
#PBS -q fas_normal
6
#PBS -l mem=2gb
7
#PBS -l walltime=1:00:00 
8
#PBS -l nodes=1:ppn=1
9
#PBS -V
10
#PBS -o /lustre0/scratch/ga254/stdout 
11
#PBS -e /lustre0/scratch/ga254/stderr
12

  
13

  
14
INDIR=/lustre0/scratch/ga254/dem_bj/GFC2013/lossyear/tif_1km
15
OUTDIR=/lustre0/scratch/ga254/dem_bj/GFC2013/lossyear
16

  
17
# md stay for meadian 
18
# mn for mean 
19

  
20
rm -f /tmp/lossyear${YEAR}_NE.tif  /tmp/lossyear${YEAR}_SE.tif  /tmp/lossyear${YEAR}_NW.tif /tmp/lossyear${YEAR}_SW.tif  /tmp/lossyear${YEAR}.tif 
21

  
22
gdal_merge.py -co  COMPRESS=LZW -co ZLEVEL=9   $INDIR/1km_y${YEAR}_Hansen_GFC2013_lossyear_??N_???E.tif -o /tmp/lossyear${YEAR}_NE.tif
23
gdal_merge.py -co  COMPRESS=LZW -co ZLEVEL=9   $INDIR/1km_y${YEAR}_Hansen_GFC2013_lossyear_??S_???E.tif -o /tmp/lossyear${YEAR}_SE.tif
24
gdal_merge.py -co  COMPRESS=LZW -co ZLEVEL=9   $INDIR/1km_y${YEAR}_Hansen_GFC2013_lossyear_??N_???W.tif -o /tmp/lossyear${YEAR}_NW.tif
25
gdal_merge.py -co  COMPRESS=LZW -co ZLEVEL=9   $INDIR/1km_y${YEAR}_Hansen_GFC2013_lossyear_??S_???W.tif -o /tmp/lossyear${YEAR}_SW.tif
26

  
27
gdal_merge.py -co  COMPRESS=LZW -co ZLEVEL=9  /tmp/lossyear${YEAR}_??.tif    -o  /tmp/lossyear${YEAR}.tif
28

  
29
gdal_translate  -co  COMPRESS=LZW -co ZLEVEL=9  /tmp/lossyear${YEAR}.tif   $OUTDIR/lossyear${YEAR}_frequency_GFC2013.tif
30

  
31
rm -f /tmp/lossyear${YEAR}.tif /tmp/lossyear${YEAR}_NE.tif  /tmp/lossyear${YEAR}_SE.tif  /tmp/lossyear${YEAR}_NW.tif /tmp/lossyear${YEAR}_SW.tif
32

  
33
for YEAR  in `seq 2 12 ` ; do  
34

  
35
YEARL=`expr 2000 + $YEAR`
36

  
37
gdal_edit.py -mo "Author=giuseppe.amatulli@gmail.com using pktools"\
38
             -mo "Input dataset=Global Forest Change 2000-2012 (Hansen 2013)"\
39
             -mo "Input layer=Year of gross forest cover loss event"\
40
             -mo "Output=Gross Forest Cover Loss during $YEARL in Frequency(%)"\
41
             -mo "Offset=0" -mo "Scale=0.01" $OUTDIR/lossyear${YEAR}_frequency_GFC2013.tif
42
mv  $OUTDIR/lossyear${YEAR}_frequency_GFC2013.tif $OUTDIR/lossyear${YEARL}_frequency_GFC2013.tif
43

  
44
done 
45

  
46

  
47
checkjob -v $PBS_JOBID
48

  
terrain/procedures/dem_variables/GFC2013/.#sc2_merge_lossyear.sh
1
ga254@bulldogj.wss.yale.edu.1470:1376934945
terrain/procedures/dem_variables/GFC2013/sc2_merge_lossyear.sh
30 30

  
31 31
rm -f /tmp/lossyear${YEAR}.tif /tmp/lossyear${YEAR}_NE.tif  /tmp/lossyear${YEAR}_SE.tif  /tmp/lossyear${YEAR}_NW.tif /tmp/lossyear${YEAR}_SW.tif
32 32

  
33

  
33 34
YEARL=`expr 2000 + $YEAR`
34 35

  
35 36
gdal_edit.py -mo "Author=giuseppe.amatulli@gmail.com using pktools"\
36 37
             -mo "Input dataset=Global Forest Change 2000-2012 (Hansen 2013)"\
37 38
             -mo "Input layer=Year of gross forest cover loss event"\
38 39
             -mo "Output=Gross Forest Cover Loss during $YEARL in Frequency(%)"\
39
             -mo "Offset=0" -mo "Scale=0.01" $OUTDIR/lossyear${YEARL}_frequency_GFC2013.tif
40
             -mo "Offset=0" -mo "Scale=0.01" $OUTDIR/lossyear${YEAR}_frequency_GFC2013.tif
41
mv  $OUTDIR/lossyear${YEAR}_frequency_GFC2013.tif $OUTDIR/lossyear${YEARL}_frequency_GFC2013.tif
40 42

  
41 43
checkjob -v $PBS_JOBID
42 44

  
terrain/procedures/dem_variables/gmted2010_rad/scripts_r_sun/sc2_solar_radiation.sh
1
# cd  /media/data/grassdb1/ 
1
# cd  /mnt/data2/scratch/GMTED2010/grassdb 
2 2
# ls  /mnt/data2/scratch/GMTED2010/tiles/mn75_grd_tif/?_?.tif  | xargs -n 1  -P 10  bash /mnt/data2/scratch/GMTED2010/scripts/sc2_solar_radiation.sh
3
# ls  /mnt/data2/scratch/GMTED2010/tiles/mn75_grd_tif/{1_1,1_2,2_1,2_2,1_0,2_0}.tif  | xargs -n 1  -P 10  bash /mnt/data2/scratch/GMTED2010/scripts/sc2_solar_radiation.sh
3 4

  
4 5
file=`basename $1 .tif`
5 6

  
......
7 8

  
8 9
export file=`basename $1`
9 10
export filename=`basename $file .tif`
10
export INDIR=/media/data/grassdb1
11 11

  
12
rm -rf  $INDIR/loc_$filename
12
export INDIRG=/media/data/grassdb1
13
export INDIRD=/mnt/data2/scratch/GMTED2010/grassdb
14

  
15
rm -rf  $INDIRG/loc_$filename
13 16
echo clip the data 
14 17

  
15
cd $INDIR
18
cd $INDIRG
16 19

  
17 20
# clip the 1km dem, use the be75_grd_tif to ensure larger overlap
18
gdal_translate -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file) /media/data/grassdb1/mn30_grd_tif/mn30_grd.tif $file
19

  
20
echo  clip albedo by $file 
21
gdal_translate -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file) $INDIRD/mn30_grd_tif/mn30_grd.tif $file
21 22

  
22
/mnt/data2/scratch/GMTED2010/scripts/create_location_gr.sh   $file   loc_$filename  $INDIR
23
echo create location 
23 24

  
25
/mnt/data2/scratch/GMTED2010/scripts/create_location_gr.sh   $file   loc_$filename  $INDIRG
26
rm -f $file 
24 27
# echo enter in grass 
25 28

  
26 29
echo "LOCATION_NAME: loc_$filename"              >  $HOME/.grassrc6$$
27 30
echo "MAPSET: PERMANENT"                         >> $HOME/.grassrc6$$
28 31
echo "DIGITIZER: none"                           >> $HOME/.grassrc6$$
29 32
echo "GRASS_GUI: text"                           >> $HOME/.grassrc6$$
30
echo "GISDBASE: /media/data/grassdb1"            >> $HOME/.grassrc6$$
33
echo "GISDBASE: $INDIRG"            >> $HOME/.grassrc6$$
31 34

  
32 35
# path to GRASS binaries and libraries:
33 36

  
......
47 50
# r.horizon elevin=$filename  horizonstep=30 horizon=horangle dist=1 maxdistance=1000
48 51

  
49 52

  
50
for day in `seq 1 365` ; do 
53
for day in `seq 1  365` ; do 
51 54

  
52 55
# import albedo 
53
gdal_translate  -a_nodata 32767   -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file)  /mnt/data2/scratch/GMTED2010/MODALB/0.3_5.0.um.00-04.WS.c004.v2.0_day_estimation/AlbMap.WS.c004.v2.0.00-04.${day}.0.3_5.0.tif  $INDIR/alb_WS/${filename}_albWS_day${day}.tif  
54 56

  
55
r.in.gdal -o input=$INDIR/alb_WS/${filename}_albWS_day${day}.tif    output=${filename}_albWS_day${day}  --overwrite 
57
cd $INDIRD 
58

  
59
# gdal_translate  -a_nodata 32767   -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file)  /mnt/data2/scratch/GMTED2010/MODALB/0.3_5.0.um.00-04.WS.c004.v2.0_day_estimation/AlbMap.WS.c004.v2.0.00-04.${day}.0.3_5.0.tif    /mnt/data2/scratch/GMTED2010/grassdb/alb_WS/${filename}_albWS_day${day}.tif  
60
# r.external  -o input=$INDIRD/alb_WS/${filename}_albWS_day${day}.tif    output=${filename}_albWS_day${day}  --overwrite 
61

  
62
r.external  -o input=/mnt/data2/scratch/GMTED2010/MODALB/0.3_5.0.um.00-04.WS.c004.v2.0_day_estimation/AlbMap.WS.c004.v2.0.00-04.${day}.0.3_5.0.tif   output=${filename}_albWS_day${day}  --overwrite 
56 63
r.mapcalc  ${filename}_albWS_day${day}_coef = " ${filename}_albWS_day${day}  * 0.001" 
57 64

  
58 65
# import Linke turbidity
......
70 77
if [ $day -ge 305 ] && [ $day -le 334 ] ; then LT=November ; fi  
71 78
if [ $day -ge 335 ] && [ $day -le 365 ] ; then LT=December ; fi 
72 79

  
73
gdal_translate   -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file) /mnt/data2/scratch/GMTED2010/linke_turbidity/${LT}.tif /mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif  
80
# gdal_translate   -projwin  $(getCorners4Gtranslate  /mnt/data2/scratch/GMTED2010/tiles/be75_grd_tif/$file) /mnt/data2/scratch/GMTED2010/linke_turbidity/${LT}.tif /mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif  
81
# r.external -o input=/mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif  output=${LT}_${filename}_day${day}  --overwrite 
82
# rm -f /mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif 
83

  
84
LTcoef=$(g.mlist type=rast pattern=${LT}_${filename}_coef)
74 85

  
75
r.in.gdal -o input=/mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif  output=${LT}_${filename}_day${day}  --overwrite 
76
rm -f /mnt/data2/scratch/GMTED2010/grassdb/linke_turbidity_clip/${LT}_${filename}_day${day}.tif 
86
if [ -z  $LTcoef ] ; then 
87
    r.external -o input=/mnt/data2/scratch/GMTED2010/linke_turbidity/${LT}.tif     output=${LT}_${filename}  --overwrite 
88
    r.mapcalc  ${LT}_${filename}_coef = "${LT}_${filename}  * 0.05 "     
89
else
90
    echo the file  ${LT}_${filename}_coef exist 
91
fi 
77 92

  
78
r.mapcalc  ${LT}_${filename}_day${day}_coef = "${LT}_${filename}_day${day}  * 0.05 " 
79 93

  
80 94
echo run r.sun 
81 95

  
82
r.sun -s  elevin=$file aspin=aspect_$filename  slopein=slope_$filename   linkein=${LT}_${filename}_day${day}_coef   albedo=${filename}_albWS_day${day}_coef day=$day step=0.5 \
96
r.sun -s  elevin=$file aspin=aspect_$filename  slopein=slope_$filename   linkein=${LT}_${filename}_coef   albedo=${filename}_albWS_day${day}_coef day=$day step=1 \
83 97
glob_rad=glob_rad_day$day"_"$filename \
84 98
diff_rad=diff_rad_day$day"_"$filename \
85 99
beam_rad=beam_rad_day$day"_"$filename \
86 100
refl_rad=refl_rad_day$day"_"$filename
87 101

  
88
g.remove rast=${LT}_${filename}_day${day}_coef
102
g.remove rast=${filename}_albWS_day${day}_coef
89 103

  
90
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=glob_rad_day$day"_"$filename    output=/media/data/grassdb1/glob_rad/${day}/glob_rad_day$day"_"$file
91
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=diff_rad_day$day"_"$filename    output=/media/data/grassdb1/diff_rad/${day}/diff_rad_day$day"_"$file
92
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=beam_rad_day$day"_"$filename    output=/media/data/grassdb1/beam_rad/${day}/beam_rad_day$day"_"$file
93
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=refl_rad_day$day"_"$filename    output=/media/data/grassdb1/refl_rad/${day}/refl_rad_day$day"_"$file
104
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=glob_rad_day$day"_"$filename    output=$INDIRD/glob_rad/${day}/glob_rad_day$day"_"$file
105
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=diff_rad_day$day"_"$filename    output=$INDIRD/diff_rad/${day}/diff_rad_day$day"_"$file
106
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=beam_rad_day$day"_"$filename    output=$INDIRD/beam_rad/${day}/beam_rad_day$day"_"$file
107
r.out.gdal -c type=Float32  nodata=-1  createopt="COMPRESS=LZW,ZLEVEL=9"  input=refl_rad_day$day"_"$filename    output=$INDIRD/refl_rad/${day}/refl_rad_day$day"_"$file
94 108

  
95 109
if [ ${filename:0:1} -eq 0 ] ; then 
96 110
# this was inserted becouse the r.out.gdal of the 0_? was overpassing the -180 border and it was attach the tile to the right border 
97
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  /media/data/grassdb1/glob_rad/${day}/glob_rad_day$day"_"$file /media/data/grassdb1/glob_rad/${day}/glob_rad_day$day"_"$file"_tmp"
98
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  /media/data/grassdb1/diff_rad/${day}/diff_rad_day$day"_"$file /media/data/grassdb1/diff_rad/${day}/diff_rad_day$day"_"$file"_tmp"
99
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  /media/data/grassdb1/beam_rad/${day}/beam_rad_day$day"_"$file /media/data/grassdb1/beam_rad/${day}/beam_rad_day$day"_"$file"_tmp"
100
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  /media/data/grassdb1/refl_rad/${day}/refl_rad_day$day"_"$file /media/data/grassdb1/refl_rad/${day}/refl_rad_day$day"_"$file"_tmp"
111
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  $INDIRD/glob_rad/${day}/glob_rad_day$day"_"$file $INDIRD/glob_rad/${day}/glob_rad_day$day"_"$file"_tmp"
112
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  $INDIRD/diff_rad/${day}/diff_rad_day$day"_"$file $INDIRD/diff_rad/${day}/diff_rad_day$day"_"$file"_tmp"
113
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  $INDIRD/beam_rad/${day}/beam_rad_day$day"_"$file $INDIRD/beam_rad/${day}/beam_rad_day$day"_"$file"_tmp"
114
gdal_translate  -a_ullr   $(getCorners4Gtranslate $file)  $INDIRD/refl_rad/${day}/refl_rad_day$day"_"$file $INDIRD/refl_rad/${day}/refl_rad_day$day"_"$file"_tmp"
101 115

  
102
mv /media/data/grassdb1/glob_rad/${day}/glob_rad_day$day"_"$file"_tmp" /media/data/grassdb1/glob_rad/${day}/glob_rad_day$day"_"$file 
103
mv /media/data/grassdb1/diff_rad/${day}/diff_rad_day$day"_"$file"_tmp" /media/data/grassdb1/diff_rad/${day}/diff_rad_day$day"_"$file 
104
mv /media/data/grassdb1/beam_rad/${day}/beam_rad_day$day"_"$file"_tmp" /media/data/grassdb1/beam_rad/${day}/beam_rad_day$day"_"$file 
105
mv /media/data/grassdb1/refl_rad/${day}/refl_rad_day$day"_"$file"_tmp" /media/data/grassdb1/refl_rad/${day}/refl_rad_day$day"_"$file 
116
mv $INDIRD/glob_rad/${day}/glob_rad_day$day"_"$file"_tmp" $INDIRD/glob_rad/${day}/glob_rad_day$day"_"$file 
117
mv $INDIRD/diff_rad/${day}/diff_rad_day$day"_"$file"_tmp" $INDIRD/diff_rad/${day}/diff_rad_day$day"_"$file 
118
mv $INDIRD/beam_rad/${day}/beam_rad_day$day"_"$file"_tmp" $INDIRD/beam_rad/${day}/beam_rad_day$day"_"$file 
119
mv $INDIRD/refl_rad/${day}/refl_rad_day$day"_"$file"_tmp" $INDIRD/refl_rad/${day}/refl_rad_day$day"_"$file 
106 120

  
107 121
fi
108 122
done 
109 123

  
124
g.mremove  type=rast pattern=*_*_*_coef
125

  
110 126
rm -f $file ~/.grassrc6$$ 
111 127

  
112 128
) 2>&1 | tee  /tmp/log_of_$file".txt"
terrain/procedures/dem_variables/gmted2010_rad/scripts_valid/nrel_station_shp.sh
1 1
cd /mnt/data2/scratch/GMTED2010/solar_radiation/nrel
2 2

  
3
echo '"X","Y"' > /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.csv
4
awk -F ","  '{ if (NR>1) print $5","$4 }' /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/csv/TMY3_StationsMeta.csv >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.csv
3
echo '"X","Y","CODE"' > /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.csv
4
awk -F ","  '{ if (NR>1) print $5","$4","$1 }' /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/csv/TMY3_StationsMeta.csv >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.csv
5 5

  
6 6
echo "<OGRVRTDataSource>" > /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
7 7
echo "    <OGRVRTLayer name=\"point\">" >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
8 8
echo "        <SrcDataSource>/mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.csv</SrcDataSource>"  >> /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
9 9
echo "	      <GeometryType>wkbPoint</GeometryType>"  >> /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
10
echo "	      <GeometryField encoding=\"PointFromColumns\" x=\"X\" y=\"Y\" /> "  >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
10
echo "	      <GeometryField encoding=\"PointFromColumns\" x=\"X\" y=\"Y\" z=\"CODE\" /> "  >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
11 11
echo "    </OGRVRTLayer>"  >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
12 12
echo "</OGRVRTDataSource>"  >>  /mnt/data2/scratch/GMTED2010/solar_radiation/nrel/shp/point.vrt
13 13

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

  
4
INDIR=/mnt/data2/dem_variables/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
url=http://gmted.cr.usgs.gov/gmted/Grid_ZipFiles/
10
echo $url"be75_grd.zip" $url"ds75_grd.zip" $url"md75_grd.zip" $url"mi75_grd.zip" $url"mn75_grd.zip" $url"mx75_grd.zip"  $url"sd75_grd.zip" | xargs -n 1 -P 7  wget  -d /mnt/data2/dem_variables/GMTED2010/zip/ $1   
11

  
12
# unzip the file using multiprocess approch  
13

  
14
ls  /mnt/data2/dem_variables/GMTED2010/zip/*.zip | xargs -n 1 -P 7 bash -c $'
15

  
16
dir=`basename $1 .zip`
17
unzip  -d  /mnt/data2/dem_variables/GMTED2010/tiles/$dir $1
18

  
19
' _ 
20

  
21
# transform to tif and tiling them using multiprocess approch   
22
# be75_grd.zip	Breakline Emphasis     , 7.5 arc-seconds
23
# ds75_grd.zip	Systematic Subsample   , 7.5 arc-seconds
24
# md75_grd.zip	Median Statistic       , 7.5 arc-seconds
25
# mi75_grd.zip	Minimum Statistic      , 7.5 arc-seconds
26
# mn75_grd.zip	Mean Statistic         , 7.5 arc-seconds
27
# mx75_grd.zip	Maximum Statistic      , 7.5 arc-seconds
28
# sd75_grd.zip	Standard Dev. Statistic, 7.5 arc-seconds
29

  
30
echo  be75_grd ds75_grd md75_grd mi75_grd mn75_grd mx75_grd sd75_grd  | xargs -n 1 -P 7 bash -c $'
31
dir=$1
32
INDIR=/mnt/data2/dem_variables/GMTED2010/tiles/$dir
33
for nx in `seq 0 9` ; do 
34
    for ny in `seq 0 4` ; do 
35
        xoff=$(echo 17280 \* $nx | bc)
36
        yoff=$(echo 13440 \* $ny | bc)
37
        xsize=17280
38
        ysize=13440
39
        gdal_translate -srcwin  $xoff $yoff $xsize $ysize  -co COMPRESS=LZW $INDIR/$dir  $INDIR"_tif"/$nx"_"$ny.tif
40
    done
41
done
42
' _ 
43

  
44
# at the end fo this process the 50 tiles tiff has been created for each of the defined component 
terrain/procedures/dem_variables/gmted2010_res_x10/sc1b_pixel_correction.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 /mnt/data2/dem_variables/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
# the values becom -93 and -80 
19

  
20
#  -93 2830
21
#  -93 2831
22
# 
23
#  -80 19449
24
#  -80 19450
25

  
26
# correction of a square box of 500 500 pixel. Set the value = to 179 as the near by pixel.
27
cd /mnt/data2/dem_variables/GMTED2010/tiles/mi75_grd_tif
28
gdal_translate  -srcwin  10070 3830 500 500   2_1.tif  2_1_clip.tif
29

  
30
pksetmask -co COMPRESS=LZW -t 0  -f 179   -i 2_1.tif   -m 2_1_clip.tif   -o 2_1_correct.tif 
31
mv 2_1.tif 2_1_orig.tiff
32
mv 2_1_correct.tif 2_1.tif 
33
rm 2_1_clip.tif
34

  
35
# correction of a square in the caspian sea set value to -27 
36
cd /mnt/data2/dem_variables/GMTED2010/tiles/mi75_grd_tif
37
gdal_translate  -srcwin  5719 5249 1050 1050   6_1.tif  6_1_clip1.tif
38
gdal_translate  -srcwin  6200 6200 1050 550    6_1.tif  6_1_clip2.tif
39
gdal_translate  -srcwin  6700 6700 1050 550    6_1.tif  6_1_clip3.tif
40
gdal_translate  -srcwin  7150 7000 550  700    6_1.tif  6_1_clip4.tif
41
gdal_translate  -srcwin  6700 7550 1050 1100   6_1.tif  6_1_clip5.tif
42
gdal_translate  -srcwin  7150 8000 1050 1150   6_1.tif  6_1_clip6.tif
43

  
44
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
45
mv  6_1.tif  6_1_orig.tiff
46
mv 6_1_correct.tif 6_1.tif
47
rm 6_1_clip*.tif
48

  
49
# correction of a square box of 500 500 pixel. Set the value = to 179 as the near by pixel.
50
cd /mnt/data2/dem_variables/GMTED2010/tiles/mx75_grd_tif
51
gdal_translate  -srcwin  10070 3830 500 500   2_1.tif  2_1_clip.tif
52

  
53
pksetmask -co COMPRESS=LZW -t 0  -f 179   -i 2_1.tif   -m 2_1_clip.tif   -o 2_1_correct.tif 
54
mv 2_1.tif 2_1_orig.tiff
55
mv 2_1_correct.tif 2_1.tif 
56
rm 2_1_clip.tif
57

  
58
# correction of a square in the caspian sea set value to -27 
59
cd /mnt/data2/dem_variables/GMTED2010/tiles/mx75_grd_tif
60
gdal_translate  -srcwin  5719 5249 1050 1050   6_1.tif  6_1_clip1.tif
61
gdal_translate  -srcwin  6200 6200 1050 550    6_1.tif  6_1_clip2.tif
62
gdal_translate  -srcwin  6700 6700 1050 550    6_1.tif  6_1_clip3.tif
63
gdal_translate  -srcwin  7150 7000 550  700    6_1.tif  6_1_clip4.tif
64
gdal_translate  -srcwin  6700 7550 1050 1100   6_1.tif  6_1_clip5.tif
65
gdal_translate  -srcwin  7150 8000 1050 1150   6_1.tif  6_1_clip6.tif
66

  
67
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
68
mv  6_1.tif  6_1_orig.tiff
69
mv 6_1_correct.tif 6_1.tif
70
rm 6_1_clip*.tif
71

  
terrain/procedures/dem_variables/gmted2010_res_x10/sc2_class_treshold_percent.sh
1
# calculate altitude area percent above a specific treshold
2
# e.g  75% of class200 means that 75% of the pixels is >= 200 
3
# for this case the treshold is set every 100 meter
4
# geting the integer of the altitued / 100
5

  
6
#  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 
7
#  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 
8
# to check 
9
# 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 
10

  
11
export file=$1
12
export mm=$2
13
export filename=`basename $file .tif`
14
(
15

  
16
INDIR=/mnt/data2/dem_variables/GMTED2010/tiles/$mm"75_grd_tif"
17
OUTDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_$mm/class
18

  
19
echo  calcualte altitude  every 100 meter  using the the Int16 factors for $file 
20

  
21
# oft-calc  -X -ot Int16 $INDIR/$filename.tif $OUTDIR/../tmp/$filename"_class_tmp1.tif"  &> /dev/null   <<EOF
22
# 1
23
# #1 49 - 100 /
24
# EOF
25

  
26
# oft-calc  -X -ot Int16  $OUTDIR/../tmp/$filename"_class_tmp1.tif"  $OUTDIR/../tmp/$filename"_class_tmp2.tif"    &> /dev/null   <<EOF
27
# 1
28
# #1 100 *
29
# EOF
30

  
31
# rm $OUTDIR/../tmp/$filename"_class_tmp1.tif" 
32
# gdal_translate -co COMPRESS=LZW -co ZLEVEL=9  $OUTDIR/../tmp/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class.tif"
33
# rm $OUTDIR/../tmp/$filename"_class_tmp2.tif"
34

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

  
37
echo min and max for $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
38

  
39
# 
40
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 
41

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

  
46
    echo applaid the filter for the classes  $class_string
47

  
48
    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 
49

  
50
done 
51

  
52

  
53
) 2>&1 | tee  /mnt/data2/dem_variables/GMTED2010/log/log_of_class_$mm"_"$filename".txt"
terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.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
# be, ds, md, mn  ; Breakline Emphasis, Systematic Subsample, Median Statistic, Mean Statistic  ; md ds 
7
# for file in `ls /mnt/data2/dem_variables/GMTED2010/tiles/be75_grd_tif/*.tif` ; do echo $file md ; done  | xargs -n 2 -P 5 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh ; 
8
# for file in `ls /mnt/data2/dem_variables/GMTED2010/tiles/be75_grd_tif/*.tif` ; do echo $file ds ; done  | xargs -n 2 -P 5 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh 
9

  
10
export file=$1
11
export mm=$2
12
export INDIR=/mnt/data2/dem_variables/GMTED2010/tiles/${mm}75_grd_tif
13
export OUTDIR=/mnt/data2/dem_variables/GMTED2010
14

  
15
export filename=`basename $file .tif`
16

  
17
( 
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
111

  
112

  
113
echo  aspect  with file   $INDIR/$filename.tif
114

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

  
117
# r1 aspect , r2 slope 
118

  
119
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(sin(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" --overwrite --type Float32
120
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(cos(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" --overwrite --type Float32
121

  
122
gdal_calc.py --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
123
gdal_calc.py --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
124

  
125
echo  aspect sin   cos  Ew  Nw   median 
126
# sin
127
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
128
oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null    <<EOF
129
1
130
#1 10000 *
131
EOF
132
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_t10k.tif"  
133
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
134
# cos
135
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
136
oft-calc  -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_f.tif"  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
137
1
138
#1 10000 *
139
EOF
140
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_t10k.tif" 
141
rm  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
142
# Ew
143
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
144
oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null   <<EOF
145
1
146
#1 10000 *
147
EOF
148
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_t10k.tif" 
149
rm  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
150
# Nw
151
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
152
oft-calc  -ot Int16  $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
153
1
154
#1 10000 *
155
EOF
156
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_t10k.tif" 
157
rm  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
158

  
159

  
160
echo aspect sin   cos  Ew  Nw   mean
161
# sin
162
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
163
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" &> /dev/null  <<EOF
164
1
165
#1 10000 *
166
EOF
167
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_t10k.tif"  
168
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
169
# cos
170
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
171
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_f.tif"  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
172
1
173
#1 10000 *
174
EOF
175
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_t10k.tif" 
176
rm  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
177
# Ew
178
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
179
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null  <<EOF
180
1
181
#1 10000 *
182
EOF
183
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_t10k.tif" 
184
rm  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
185
# Nw
186
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
187
oft-calc  -ot Int16  $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
188
1
189
#1 10000 *
190
EOF
191
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
192
1
193
#1 10000 *
194
EOF
195
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_t10k.tif" 
196
rm  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
197

  
198
echo aspect sin   cos  Ew  Nw   max
199
# sin
200
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
201
oft-calc -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"   &> /dev/null  <<EOF
202
1
203
#1 10000 *
204
EOF
205
gdal_translate  -co COMPRESS=LZW  -ot Int16 /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_t10k.tif"  
206
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
207
# cos
208
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
209
oft-calc  -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_f.tif"   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
210
1
211
#1 10000 *
212
EOF
213
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_t10k.tif" 
214
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
215
# Ew
216
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
217
oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
218
1
219
#1 10000 *
220
EOF
221
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_t10k.tif" 
222
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
223
# Nw
224
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
225
oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
226
1
227
#1 10000 *
228
EOF
229
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_t10k.tif" 
230
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
231

  
232
echo aspect sin   cos  Ew  Nw   min 
233
# sin
234
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
235
oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_f.tif"   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null   <<EOF
236
1
237
#1 10000 *
238
EOF
239
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_t10k.tif"  
240
rm   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
241
# cos
242
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
243
oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_f.tif"   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
244
1
245
#1 10000 *
246
EOF
247
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_t10k.tif" 
248
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
249
# Ew
250
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
251
oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
252
1
253
#1 10000 *
254
EOF
255
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_t10k.tif" 
256
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
257
# Nw
258
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
259
oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
260
1
261
#1 10000 *
262
EOF
263
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_t10k.tif" 
264
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
265

  
266
echo aspect sin   cos  Ew  Nw   stdev
267
# stdev   
268
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
269
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"
270
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_t10k.tif"  
271
rm   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
272
# cos
273
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
274
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"
275
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_t10k.tif" 
276
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
277
# Ew
278
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
279
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"
280
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_t10k.tif" 
281
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
282
# Nw
283
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
284
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"
285
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_t10k.tif" 
286
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
287

  
288
) 2>&1 | tee  /mnt/data2/dem_variables/GMTED2010/log_${mm}.txt
terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.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
DIR=$1
10
mm=$2
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
OUTDIR=/mnt/data2/dem_variables/GMTED2010/altitude/percent_class_${mm}
14

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

  
17
for file  in `ls $INDIR_C/*.tif`  ; do 
18
    tile=`basename $file _class.tif`
19

  
20
    if [ -f $INDIR/$tile"_C"$DIR"Perc.tif" ] ; then 
21
	echo the file  $INDIR/$tile"_C"$DIR"Perc.tif"   exist and will be merged as it is
22
	echo $tile"_C"$DIR"Perc.tif" >>  $OUTDIR/file_processed_sc3.txt # usefull to list file processed by script sc1, in case of delatio use this.
23
    else
24

  
25
gdalinfo -mm /mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class/$tile"_class.tif"  | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt
26

  
27
min=`awk '{ print $1}'  /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt`  
28
max=`awk '{ print $2}'  /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt`
29
rm -f  /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt
30

  
31
echo $min and $max compare to $DIR
32

  
33
if [ $max -lt $DIR ]  ;  then 
34
      echo building the $INDIR/$tile"_C"$DIR"Perc.tif"  with 0 value
35
      pkgetmask -min 10000 -max 10001  -t 0 -ot Byte -i  $INDIR_C/$tile"_class.tif" -co COMPRESS=LZW  -o $INDIR/$tile"_C"$DIR"Perc.tif" 
36
      
37
fi 
38

  
39
if [ $min -gt $DIR ] ; then 
40
      echo building the $INDIR/$tile"_C"$DIR"Perc.tif"  with 100 value 
41
      pkgetmask -min 10000 -max 10001  -t 0 -f 100  -ot Byte  -co COMPRESS=LZW  -i $INDIR_C/$tile"_class.tif"  -o $INDIR/$tile"_C"$DIR"Perc.tif" 
42
      
43
fi 
44

  
45
fi  
46

  
47
done
48
rm -f $OUTDIR/perc_$DIR.tif
49
gdal_merge.py   -co COMPRESS=LZW    -ot Byte -o $OUTDIR/perc_$DIR.tif  $INDIR/*.tif 
50

  
51
if [ -f $OUTDIR/color-bw.txt ] ; then 
52
    echo the $OUTDIR/color-bw.txt exist ;
53
else 
54
    pkcreatect -g -min 0 -max 100 | sort -k 1,1 -rg | awk '{  print NR-1 , $2 ,$3 ,$4 ,$5 }'  >  $OUTDIR/color-bw.txt
55
fi 
56

  
57
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/perc_${DIR}_tmp.tif 
58
mv  $OUTDIR/perc_${DIR}_tmp.tif   $OUTDIR/perc_${DIR}.tif 
terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tilingLarg_gmted2010-7.5_bj.sh
13 13
# rm     /lustre0/scratch/ga254/stdout/*  /lustre0/scratch/ga254/stderr/*
14 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/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tiling_gmted2010-7.5_bj.sh ; done
15 15

  
16
# for DIR in  be75_grd  ; do  bash   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tiling_gmted2010-7.5_bj.sh $DIR ; done
16
# for DIR in  be75_grd  ; do  bash   /lustre0/scratch/ga254/scripts_bj/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_tilingLarg_gmted2010-7.5_bj.sh $DIR ; done
17 17

  
18 18

  
19 19
#PBS -S /bin/bash 
......
37 37

  
38 38
module load Tools/Python/2.7.3
39 39
module load Libraries/GDAL/1.10.0
40
module load Tools/PKTOOLS/2.4.2
40
# module load Tools/PKTOOLS/2.4.2
41 41
module load Libraries/OSGEO/1.10.0
42 42

  
43 43

  
......
65 65

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

  
72 72
' _ 
......
84 84
INDIR=/lustre0/scratch/ga254/dem_bj/GMTED2010/tiles
85 85

  
86 86
    # get greenland mn and paste in mn md mx mn be
87
    if [  $DIR = mn75_grd ] ||  [  $DIR=md75_grd  ] ||  [  $DIR=mx75_grd ]   ||  [  $DIR=mn75_grd  ] || $DIR = be75_grd ] ; then 
88
    echo $DIR  $tile 
89
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
87
    if [  ${DIR} = mn75_grd ] ||  [  ${DIR}=md75_grd  ] ||  [  ${DIR}=mx75_grd ]   ||  [  ${DIR}=mn75_grd  ] || ${DIR} = be75_grd ] ; then 
88
    echo ${DIR}  $tile 
89
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
90 90
    fi 
91 91
    # get greenland ds and paste in ds 
92
    if [  $DIR = ds75_grd ]  ; then 
93
    echo $DIR $tile 
94
    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
92
    if [  ${DIR} = ds75_grd ]  ; then 
93
    echo ${DIR} $tile 
94
    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
95 95
    fi 
96 96
    # standard deviation not computed for greenland becouse == to 0
97 97

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

  
100
mv $INDIR/$DIR"_tif"/${tile}g.tif $INDIR/$DIR"_tif"/${tile}.tif
100
mv $INDIR/${DIR}_tif/${tile}g.tif $INDIR/${DIR}_tif/${tile}.tif
101 101

  
102 102
' _ 
103 103

  
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

  

Also available in: Unified diff