from osgeo import gdal import sys # this allows GDAL to throw Python Exceptions gdal.UseExceptions() try: src_ds = gdal.Open( "INPUT.tif" ) except RuntimeError, e: print 'Unable to open INPUT.tif' print e sys.exit(1) try: srcband = src_ds.GetRasterBand(1) except RuntimeError, e: # for example, try GetRasterBand(10) print 'Band ( %i ) not found' % band_num print e sys.exit(1)
得到一个光栅带。注意我们如何处理运行时错误,这个函数可能会引发。
Copyright © Since 2014.
开源地理空间基金会中文分会
吉ICP备05002032号
Powered by TorCMS