I have a geotiff file with many bands...
I will like to create a .asc file or tiff file by converting only one band from the geotiff file.
I don't find the solution by using python...
With os.system, i use:
os.system("gdal_translate -b 4 -of AAIGrid C:\in.tif C:\out_onlyband4.asc")
it is ok, but i will like to use by from osgeo import gdal
... How can i do that?
from osgeo import gdal
drv = gdal.GetDriverByName('AAIGrid')
ds_in = gdal.Open('in.tif')
#i just want to extract one band (sample 4...) and create AAIGrid or GTiff with only one band, can you help me?
ds_out = drv.CreateCopy('out_onlyband4.asc', ds_in)
ds_in = None
ds_out = None