-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpan_sharpen_RGB.py
More file actions
54 lines (33 loc) · 1.43 KB
/
pan_sharpen_RGB.py
File metadata and controls
54 lines (33 loc) · 1.43 KB
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
from gdal_utilities import gdal_utils
import os
import pandas as pd
def main():
''' Performs Pansharpening with RGB bands and Panchromatic Band.'''
# Base Address
inDir = os.getcwd()
# Train-images multiploygon co-ordinates
df = pd.read_csv(os.path.join(inDir,'Data/train_wkt_v4.csv'))
print(df.head())
# Distinct imageIds in the DataFrame
trainImageIds = []
for i in range(len(df)):
string = (df.iloc[i,0])
if string not in trainImageIds:
trainImageIds.append(string)
print("The are " + str(len(trainImageIds)) + " distinct ids." + str(df.head()))
trainImageIds.sort()
creator = gdal_utils()
for imageID in trainImageIds:
string_base = "gdal_sharpen.py "
bands = "-b 1 -b 2 -b 3 "
panchro = os.path.join(inDir,"Data/sixteen_band/" + imageID + "_P.tif " )
print(panchro)
rgb = os.path.join(inDir,"Data/three_band/" + imageID + ".tif " )
print(rgb)
output = os.path.join(inDir,"Data/pan_sharpened_images/" + imageID + "_RGB.tif" )
print(output)
final = string_base + bands + panchro + rgb + output
print(final)
creator.gdal_pansharpen(final)
if __name__ == '__main__':
main()