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
| Name | Type | Description |
|---|
| source | [GDALRaster](../source/gdalraster.md?sid=django_contrib_gis_gdal_raster_source_gdalraster) | The parent GDALRaster object containing the band. |
| index | int | The index of the raster band to retrieve. |
Methods
description()
@classmethod
def description() - > string
Return the description string of the band.
Returns
| Type | Description |
|---|
string | The descriptive string associated with the raster band. |
width()
@classmethod
def width() - > integer
Width (X axis) in pixels of the band.
Returns
| Type | Description |
|---|
integer | The horizontal dimension of the band in pixels. |
height()
@classmethod
def height() - > integer
Height (Y axis) in pixels of the band.
Returns
| Type | Description |
|---|
integer | The vertical dimension of the band in pixels. |
pixel_count()
@classmethod
def pixel_count() - > integer
Return the total number of pixels in this band.
Returns
| Type | Description |
|---|
integer | The 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
| Name | Type | Description |
|---|
| refresh | boolean = False | Forces re-computation from the raw data and updates the cache. |
| approximate | boolean = False | Allows computation based on overviews or image tiles for faster results. |
Returns
| Type | Description |
|---|
object | A 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
| Type | Description |
|---|
number | The lowest pixel value found in the band. |
max()
@classmethod
def max() - > number
Return the maximum pixel value for this band.
Returns
| Type | Description |
|---|
number | The highest pixel value found in the band. |
mean()
@classmethod
def mean() - > number
Return the mean of all pixel values of this band.
Returns
| Type | Description |
|---|
number | The 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
| Type | Description |
|---|
number | The 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
| Type | Description |
|---|
number | The 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
| Name | Type | Description |
|---|
| value | number | The numeric value to be used as the nodata marker, or None to delete it. |
Returns
datatype()
@classmethod
def datatype(
as_string: boolean = False
) - > string|integer
Return the GDAL Pixel Datatype for this band.
Parameters
| Name | Type | Description |
|---|
| as_string | boolean = False | Determines whether to return the type as a string name instead of an integer ID. |
Returns
| Type | Description |
|---|
| `string | integer` |
color_interp()
@classmethod
def color_interp(
as_string: boolean = False
) - > string|integer
Return the GDAL color interpretation for this band.
Parameters
| Name | Type | Description |
|---|
| as_string | boolean = False | Determines whether to return the interpretation as a string name. |
Returns
| Type | Description |
|---|
| `string | integer` |
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
| Name | Type | Description |
|---|
| data | object = None | The input data to write to the band; if None, the method performs a read operation. |
| offset | tuple = None | The (x, y) pixel coordinates where the data access begins. |
| size | tuple = None | The (width, height) dimensions of the data block to access. |
| shape | tuple = None | The desired shape of the resulting data array. |
| as_memoryview | boolean = False | If True, returns the data as a memoryview instead of an array or list. |
Returns
| Type | Description |
|---|
| `array | memoryview` |