-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path04_merge_tifs.sh
59 lines (49 loc) · 1.58 KB
/
04_merge_tifs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#############################
## preliminary information ##
#############################
# open script as './04_merge_tifs.sh DATE LEVEL USE'
# DATE as YYYYMMDD without quotes
# LEVEL: processing level of the sentinel data, either L1C or L2A
# USE: either TRAIN to generate training data (parameter files are appended)
# or NEW to generate data for classfication (area file is appended)
DATE=$1
LEVEL=$2
USE=$3
PARAM=BOART_N
###############
## set paths ##
###############
# get path of current directory
CHDIR=$PWD
# set path to Bodenart tif files
PATH_TIF=${CHDIR}/data/shapefile/gt_params_files
if [ ${USE} = TRAIN ]
then
PATH_DATA=${CHDIR}/data/training_data/${DATE}_data
else
PATH_DATA=${CHDIR}/data/new_data/${DATE}_data
fi
if [ ! -d ${PATH_DATA} ]
then
mkdir ${PATH_DATA}
fi
# set path to all_bands.tif:
#
PATH_SENTINEL=${CHDIR}/data/sentinel/level_${LEVEL}
# find corresponding subdirectory by looking for the right date
FILE_DIR=$( ls ${PATH_SENTINEL} | egrep ${DATE} )
# build full path to ..._all_bands.tif
PATH_SENTINEL=${PATH_SENTINEL}/${FILE_DIR}
# merge files
if [ ${USE} = TRAIN ]
then
echo
echo "merge sentinel file with rasterized file of parameter ${PARAM}..."
gdal_merge.py -separate -of GTiff -ot float64 -o ${DATE}_${LEVEL}_merged.tif ${PATH_SENTINEL}/${DATE}_${LEVEL}_all_bands.tif ${PATH_TIF}/${PARAM}.tif
else
echo
echo "merge sentinel file with area.tif..."
gdal_merge.py -separate -of GTiff -ot float64 -o ${DATE}_${LEVEL}_merged.tif ${PATH_SENTINEL}/${DATE}_${LEVEL}_all_bands.tif ${PATH_TIF}/area.tif
fi
mv ${DATE}_${LEVEL}_merged.tif ${PATH_DATA}