Skip to main content

GDALBand

Wrap a GDAL raster band, needs to be obtained from a GDALRaster object.

Constructor

Signature

def GDALBand(
source: [GDALRaster](../source/gdalraster.md?sid=django_contrib_gis_gdal_raster_source_gdalraster),
index: int
) - > null

Parameters

NameTypeDescription
source[GDALRaster](../source/gdalraster.md?sid=django_contrib_gis_gdal_raster_source_gdalraster)The parent GDALRaster object containing the band.
indexintThe index of the raster band to retrieve.

Methods


description()

@classmethod
def description() - > string

Return the description string of the band.

Returns

TypeDescription
stringThe descriptive string associated with the raster band.

width()

@classmethod
def width() - > integer

Width (X axis) in pixels of the band.

Returns

TypeDescription
integerThe horizontal dimension of the band in pixels.

height()

@classmethod
def height() - > integer

Height (Y axis) in pixels of the band.

Returns

TypeDescription
integerThe vertical dimension of the band in pixels.

pixel_count()

@classmethod
def pixel_count() - > integer

Return the total number of pixels in this band.

Returns

TypeDescription
integerThe product of the band's width and height.

statistics()

@classmethod
def statistics(
refresh: boolean = False,
approximate: boolean = False
) - > object

Compute statistics on the pixel values of this band.

Parameters

NameTypeDescription
refreshboolean = FalseForces re-computation from the raw data and updates the cache.
approximateboolean = FalseAllows computation based on overviews or image tiles for faster results.

Returns

TypeDescription
objectA tuple containing (minimum, maximum, mean, standard deviation). Values are None for empty bands.

min()

@classmethod
def min() - > number

Return the minimum pixel value for this band.

Returns

TypeDescription
numberThe lowest pixel value found in the band.

max()

@classmethod
def max() - > number

Return the maximum pixel value for this band.

Returns

TypeDescription
numberThe highest pixel value found in the band.

mean()

@classmethod
def mean() - > number

Return the mean of all pixel values of this band.

Returns

TypeDescription
numberThe average value of all pixels in the band.

std()

@classmethod
def std() - > number

Return the standard deviation of all pixel values of this band.

Returns

TypeDescription
numberThe standard deviation of the pixel values.

nodata_value()

@classmethod
def nodata_value() - > number

Return the nodata value for this band, or None if it isn't set.

Returns

TypeDescription
numberThe numeric value representing missing data, or None if undefined.

nodata_value()

@classmethod
def nodata_value(
value: number
) - > null

Set the nodata value for this band.

Parameters

NameTypeDescription
valuenumberThe numeric value to be used as the nodata marker, or None to delete it.

Returns

TypeDescription
null

datatype()

@classmethod
def datatype(
as_string: boolean = False
) - > string|integer

Return the GDAL Pixel Datatype for this band.

Parameters

NameTypeDescription
as_stringboolean = FalseDetermines whether to return the type as a string name instead of an integer ID.

Returns

TypeDescription
`stringinteger`

color_interp()

@classmethod
def color_interp(
as_string: boolean = False
) - > string|integer

Return the GDAL color interpretation for this band.

Parameters

NameTypeDescription
as_stringboolean = FalseDetermines whether to return the interpretation as a string name.

Returns

TypeDescription
`stringinteger`

data()

@classmethod
def data(
data: object = None,
offset: tuple = None,
size: tuple = None,
shape: tuple = None,
as_memoryview: boolean = False
) - > array|memoryview

Read or writes pixel values for this band. Blocks of data can be accessed by specifying the width, height and offset of the desired block.

Parameters

NameTypeDescription
dataobject = NoneThe input data to write to the band; if None, the method performs a read operation.
offsettuple = NoneThe (x, y) pixel coordinates where the data access begins.
sizetuple = NoneThe (width, height) dimensions of the data block to access.
shapetuple = NoneThe desired shape of the resulting data array.
as_memoryviewboolean = FalseIf True, returns the data as a memoryview instead of an array or list.

Returns

TypeDescription
`arraymemoryview`