Commit a450d0e9 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

rgb l2

parent f1f93de4
...@@ -35,26 +35,19 @@ def rasterWkt(wkt, inputfile, outputfile): ...@@ -35,26 +35,19 @@ def rasterWkt(wkt, inputfile, outputfile):
intput = gdal.Open(inputfile) intput = gdal.Open(inputfile)
rows, cols, geotransform = intput.RasterYSize, intput.RasterXSize, intput.GetGeoTransform() rows, cols, geotransform = intput.RasterYSize, intput.RasterXSize, intput.GetGeoTransform()
# Read the input bands as numpy arrays. # Read the input bands as numpy arrays.
np_intput_1 = intput.GetRasterBand(1).ReadAsArray(0,0,cols,rows)
np_intput_2 = intput.GetRasterBand(2).ReadAsArray(0,0,cols,rows)
np_intput_3 = intput.GetRasterBand(3).ReadAsArray(0,0,cols,rows)
driverTiff = gdal.GetDriverByName('GTiff') driverTiff = gdal.GetDriverByName('GTiff')
output = driverTiff.Create(outputfile, cols, rows, 3, gdal.GDT_Byte) output = driverTiff.Create(outputfile, cols, rows, 3, gdal.GDT_Byte)
print ("BANDS") print ("BANDS")
print (output.RasterCount) print (output.RasterCount)
output.GetRasterBand(1).SetNoDataValue(-99) for b in range(output.RasterCount):
output.GetRasterBand(1).WriteArray(np_intput_1) np_input = intput.GetRasterBand(b).ReadAsArray(0,0,cols,rows)
output.GetRasterBand(1).FlushCache() output.GetRasterBand(b).SetNoDataValue(-99)
output.GetRasterBand(b).WriteArray(np_input)
output.GetRasterBand(2).SetNoDataValue(-99) output.GetRasterBand(b).FlushCache()
output.GetRasterBand(2).WriteArray(np_intput_2)
output.GetRasterBand(2).FlushCache()
output.GetRasterBand(3).SetNoDataValue(-99)
output.GetRasterBand(3).WriteArray(np_intput_3)
output.GetRasterBand(3).FlushCache()
output.SetGeoTransform(geotransform) output.SetGeoTransform(geotransform)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment