11
11
a = np .ones ((20 ,20 ))
12
12
13
13
I [a == 1 ]= 3
14
- print (I )
14
+ print (I )
15
+
16
+ #"E:\ALOSPALSAR\TrainData\ALPSRP267211510\ALPSRP267211510_spe_48_4bands\ALPSRP267211510_spe48_0_4b_0.tif"
17
+ import numpy as np
18
+ from osgeo import gdal
19
+ from scipy import fftpack
20
+ import cv2
21
+
22
+ # "E:\ALOSPALSAR\TrainData\ALPSRP267211510\ALPSRP267211510_spe_48.txt"
23
+ ds = gdal .Open (r'E:\ALOSPALSAR\Greenland201101\510\ALOS-P1_1__A-ORBIT__ALPSRP267211510_Cal_ML.tif' )
24
+
25
+ spectrogramtxt = open ('E:\ALOSPALSAR\TrainData\ALPSRP267211510\ALPSRP267211510_spe_48.txt' , 'r' )
26
+ lines = spectrogramtxt .readlines ()
27
+ print (len (lines ))
28
+ print (lines [467 ])
29
+ size = 24
30
+
31
+ #"E:\ALOSPALSAR\TrainData\ALPSRP267211510\ALPSRP267211510_spe_48_4bands.txt"
32
+ spetxt = open ('E:\ALOSPALSAR\TrainData\ALPSRP267211510\ALPSRP267211510_spe_48_4bands.txt' , 'w' )
33
+ def write_img (filename , XSIZE , YSIZE , Bands , DataType , np1 , np2 , np3 ):
34
+ gtiff_driver = gdal .GetDriverByName ('GTiff' )
35
+ out_ds = gtiff_driver .Create (filename ,
36
+ XSIZE , YSIZE , Bands , DataType )
37
+ out_ds .SetProjection (ds .GetProjection ())
38
+ out_ds .SetGeoTransform (ds .GetGeoTransform ())
39
+
40
+ out_band = out_ds .GetRasterBand (1 )
41
+ out_band .WriteArray (np1 )
42
+ out_band = out_ds .GetRasterBand (2 )
43
+ out_band .WriteArray (np2 )
44
+ out_band = out_ds .GetRasterBand (3 )
45
+ out_band .WriteArray (np3 )
46
+ return
47
+
48
+ path1 = (lines [1 ]).split (" " )[0 ]
49
+ path2 = (lines [1 ]).split (" " )[0 ]
50
+ path3 = (lines [1 ]).split (" " )[0 ]
51
+ path4 = (lines [1 ]).split (" " )[0 ]
52
+ print (path1 )
53
+ ds1 = gdal .Open (str (path1 ))
54
+ band1 = ds1 .GetRasterBand (1 )
55
+ spe1 = band1 .ReadAsArray ()
56
+ img = np .array ([spe1 , spe1 ,spe1 ])
57
+
58
+ write_img ('test.tif' ,24 ,24 ,3 ,band1 .DataType ,spe1 ,spe1 ,spe1 )
59
+
60
+
61
+
62
+
0 commit comments