Commit 3e06d14a authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

rgb l2

parent 45a0d280
...@@ -35,25 +35,25 @@ def rasterWkt(wkt, inputfile, outputfile): ...@@ -35,25 +35,25 @@ 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_1 = intput.GetRasterBand(0).ReadAsArray(0,0,cols,rows)
np_intput_2 = intput.GetRasterBand(2).ReadAsArray(0,0,cols,rows) np_intput_2 = intput.GetRasterBand(1).ReadAsArray(0,0,cols,rows)
np_intput_3 = intput.GetRasterBand(3).ReadAsArray(0,0,cols,rows) np_intput_3 = intput.GetRasterBand(2).ReadAsArray(0,0,cols,rows)
driverTiff = gdal.GetDriverByName('GTiff') driverTiff = gdal.GetDriverByName('GTiff')
output = driverTiff.Create(outputfile, cols, rows, 1, gdal.GDT_Byte) output = driverTiff.Create(outputfile, cols, rows, 1, gdal.GDT_Byte)
output.GetRasterBand(0).SetNoDataValue(-99)
output.GetRasterBand(0).WriteArray(np_intput_1)
output.GetRasterBand(0).FlushCache()
output.GetRasterBand(1).SetNoDataValue(-99) output.GetRasterBand(1).SetNoDataValue(-99)
output.GetRasterBand(1).WriteArray(np_intput_1) output.GetRasterBand(1).WriteArray(np_intput_2)
output.GetRasterBand(1).FlushCache() output.GetRasterBand(1).FlushCache()
output.GetRasterBand(2).SetNoDataValue(-99) output.GetRasterBand(2).SetNoDataValue(-99)
output.GetRasterBand(2).WriteArray(np_intput_2) output.GetRasterBand(2).WriteArray(np_intput_3)
output.GetRasterBand(2).FlushCache() 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)
sr = osr.SpatialReference() sr = osr.SpatialReference()
......
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