本文整理匯總了Python中osgeo.gdal.GMF_ALPHA屬性的典型用法代碼示例。如果您正苦於以下問題:Python gdal.GMF_ALPHA屬性的具體用法?Python gdal.GMF_ALPHA怎麽用?Python gdal.GMF_ALPHA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類osgeo.gdal
的用法示例。
在下文中一共展示了gdal.GMF_ALPHA屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: nb_data_bands
# 需要導入模塊: from osgeo import gdal [as 別名]
# 或者: from osgeo.gdal import GMF_ALPHA [as 別名]
def nb_data_bands(dataset):
"""
Return the number of data (non-alpha) bands of a gdal dataset
"""
alphaband = dataset.GetRasterBand(1).GetMaskBand()
if ((alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or
dataset.RasterCount == 4 or
dataset.RasterCount == 2):
return dataset.RasterCount - 1
else:
return dataset.RasterCount
示例2: open_inumpyut
# 需要導入模塊: from osgeo import gdal [as 別名]
# 或者: from osgeo.gdal import GMF_ALPHA [as 別名]
def open_inumpyut(self,vrt):
if vrt:
self.in_ds = gdal.Open(vrt, gdal.GA_ReadOnly)
else:
raise Exception("No vrt file was specified")
if self.options.verbose:
print("Inumpyut file:", "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, self.in_ds.RasterCount))
if not self.in_ds:
# Note: GDAL prints the ERROR message too
self.error("It is not possible to open the inumpyut file '%s'." % vrt )
if self.in_ds.RasterCount == 0:
self.error( "Inumpyut file '%s' has no raster band" % vrt )
self.out_ds = self.in_ds
# Get alpha band (either directly or from NODATA value)
self.alphaband = self.out_ds.GetRasterBand(1).GetMaskBand()
if (self.alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or self.out_ds.RasterCount==4 or self.out_ds.RasterCount==2:
self.dataBandsCount = self.out_ds.RasterCount - 1
else:
self.dataBandsCount = self.out_ds.RasterCount
# -------------------------------------------------------------------------