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): ...@@ -32,22 +32,22 @@ def rasterWkt(wkt, inputfile, outputfile):
print (wkt) print (wkt)
print (inputfile) print (inputfile)
print (outputfile) print (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 = intput.GetRasterBand(1).ReadAsArray(0,0,cols,rows) # np_intput = intput.GetRasterBand(1).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(1).SetNoDataValue(-99) # output.GetRasterBand(1).SetNoDataValue(-99)
output.GetRasterBand(1).WriteArray(np_intput) # output.GetRasterBand(1).WriteArray(np_intput)
output.GetRasterBand(1).FlushCache() # output.GetRasterBand(1).FlushCache()
output.SetGeoTransform(geotransform) # output.SetGeoTransform(geotransform)
wkt = intput.GetProjection() # wkt = intput.GetProjection()
sr = osr.SpatialReference() # sr = osr.SpatialReference()
sr.ImportFromWkt(wkt) # sr.ImportFromWkt(wkt)
output.SetProjection(sr.ExportToWkt()) # output.SetProjection(sr.ExportToWkt())
# shapefile # shapefile
...@@ -62,12 +62,12 @@ def rasterWkt(wkt, inputfile, outputfile): ...@@ -62,12 +62,12 @@ def rasterWkt(wkt, inputfile, outputfile):
feature.SetGeometry(geometry) feature.SetGeometry(geometry)
layer.CreateFeature(feature) layer.CreateFeature(feature)
gdal.RasterizeLayer(output, [1], layer, burn_values=[0]) # gdal.RasterizeLayer(output, [1], layer, burn_values=[0])
feature = None feature = None
data_source = None data_source = None
output = None # output = None
def main(argv): def main(argv):
rasterWkt(argv[1], argv[2], argv[3]) 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