gdal ReadAsArray支持按块读取影像,有两种方式:
(1)针对dataset
dataset = gdal.Open(file, gdal.GA_ReadOnly)
data = dataset.ReadAsArray(xoff=0, yoff=0, xsize=512, ysize=512)
(2)针对band
dataset = gdal.Open(file, gdal.GA_ReadOnly)
band = dataset.GetBand(0)
data = band.ReadAsArray(xoff=0, yoff=0, win_xsize=512, win_ysize=512)
注意:dataset和band模式中参数不同xsize和win_xsize
ReadAsArray定义:
# dataset.ReadAsArray
def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None,
buf_xsize = None, buf_ysize = None, buf_type = None,
resample_alg = GRIORA_NearestNeighbour,
callback = None,
callback_data = None):
""" Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type) parameters should generally not be specified if buf_obj is specified. The array is returned"""
# band.ReadAsArray
def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,
buf_xsize=None, buf_ysize=None, buf_type=None, buf_obj=None,
resample_alg = GRIORA_NearestNeighbour,
callback = None,
callback_data = None):
""" Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type) parameters should generally not be specified if buf_obj is specified. The array is returned"""
r
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)