-
Notifications
You must be signed in to change notification settings - Fork 0
/
queryRSAll.sh
29 lines (25 loc) · 964 Bytes
/
queryRSAll.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
#!/bin/bash
# Query A Single Pixel in all images
#------------------------------------------------------------
# Arguments: bash queryRSAll.sh $1 $2 $3 $4
#------------------------------------------------------------
# $1 : Source directory (with many Raster images i.e. ~/RSDATA/)
# $2 : Longitude coordinate of the Raster image (North-South)
# $3 : Latitude coordinate of the Raster image (East-West)
# $4 : One of the Indices: NDVI NDWI LSWI NBR2
#------------------------------------------------------------
# Returns a set of pixel values in STDOUT
# can be caught by Python subprocess()
#------------------------------------------------------------
# Identify the Index
VI=$4
# Process search for pixel values
cd $1
for file in $(ls *$VI.tif)
do
dateT=$(echo $file | sed 's/LC08......\(.*\)..T.-\(.*\)/\1/')
if [[ $(gdallocationinfo -valonly -wgs84 $file $2 $3) -ne "" ]]
then
echo $dateT","$(gdallocationinfo -valonly -wgs84 $file $2 $3)
fi
done