使用 python gdal 读取 netCDF 文件(.nc)
如何使用 python gdal 读取 netCDF 文件(.nc)?
import gdal
# Path of netCDF file
netcdf_fname = "/filepath/PREVIMER_WW3-GLOBAL-30MIN.nc"
# Specify the layer name to read
layer_name = "hs"
# Open netcdf file.nc with gdal
ds = gdal.Open("NETCDF:{0}:{1}".format(netcdf_name, layer_name))
# Read full data from netcdf
data = ds.ReadAsArray(0, 0, ds.RasterXSize, ds.RasterYSize)
data[data < 0] = 0