python 读取h5格式的遥感影像
import gdal
file = r"D:\COSMO\CSKS1_GEC_B_HI_10_VV_RD_FF_20180115091818_20180115091825.h5"
tiff_file =r"D:\test\test.tif"
ds = gdal.Open(file)
subdatasets=ds.GetSubDatasets()
print(subdatasets)
dataset = gdal.Open(subdatasets[1][0])
cols = dataset.RasterXSize
rows = dataset.RasterYSize
geos = dataset.GetGeoTransform()
proj = dataset.GetProjection()
band = dataset.GetRasterBand(1)
data_array = band.ReadAsArray()
print(dataset)
print(geos,proj)
driver = gdal.GetDriverByName("Gtiff")
outdataset = driver.Create(tiff_file, cols, rows, 1, gdal.GDT_Int16)
outdataset.SetGeoTransform(geos)
outdataset.SetProjection(proj)
outband = outdataset.GetRasterBand(1)
outband.WriteArray(data_array)
outband.SetNoDataValue(0)