Commit 1b66501e authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

rgb l2

parent 57c6e363
......@@ -32,22 +32,22 @@ def rasterWkt(wkt, inputfile, outputfile):
print (wkt)
print (inputfile)
print (outputfile)
intput = gdal.Open(inputfile)
rows, cols, geotransform = intput.RasterYSize, intput.RasterXSize, intput.GetGeoTransform()
# Read the input bands as numpy arrays.
np_intput = intput.GetRasterBand(1).ReadAsArray(0,0,cols,rows)
# intput = gdal.Open(inputfile)
# rows, cols, geotransform = intput.RasterYSize, intput.RasterXSize, intput.GetGeoTransform()
# # Read the input bands as numpy arrays.
# np_intput = intput.GetRasterBand(1).ReadAsArray(0,0,cols,rows)
driverTiff = gdal.GetDriverByName('GTiff')
output = driverTiff.Create(outputfile, cols, rows, 1, gdal.GDT_Byte)
output.GetRasterBand(1).SetNoDataValue(-99)
output.GetRasterBand(1).WriteArray(np_intput)
output.GetRasterBand(1).FlushCache()
output.SetGeoTransform(geotransform)
wkt = intput.GetProjection()
sr = osr.SpatialReference()
sr.ImportFromWkt(wkt)
output.SetProjection(sr.ExportToWkt())
# driverTiff = gdal.GetDriverByName('GTiff')
# output = driverTiff.Create(outputfile, cols, rows, 1, gdal.GDT_Byte)
# output.GetRasterBand(1).SetNoDataValue(-99)
# output.GetRasterBand(1).WriteArray(np_intput)
# output.GetRasterBand(1).FlushCache()
# output.SetGeoTransform(geotransform)
# wkt = intput.GetProjection()
# sr = osr.SpatialReference()
# sr.ImportFromWkt(wkt)
# output.SetProjection(sr.ExportToWkt())
# shapefile
......@@ -62,12 +62,12 @@ def rasterWkt(wkt, inputfile, outputfile):
feature.SetGeometry(geometry)
layer.CreateFeature(feature)
gdal.RasterizeLayer(output, [1], layer, burn_values=[0])
# gdal.RasterizeLayer(output, [1], layer, burn_values=[0])
feature = None
data_source = None
output = None
# output = None
def main(argv):
rasterWkt(argv[1], argv[2], argv[3])
......
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