Class: QgsSortedRasterBlockIndex¶
Creates a flat index over a QgsRasterBlock, sorted by cell
values.
This index allows for efficient retrieval of raster block cells by their sorted order. The index is sorted once during initialization, and cell values or coordinates can be requested in either ascending or descending order on demand.
Warning
Because nodata cells are ignored during index creation, the total number
of indexed cells is limited to sortedCount(). Do not attempt to retrieve ranks
outside of this range.
Warning
Raster block data is not stored in this class, and the source QgsRasterBlock must exist for the lifetime of this object.
Added in version 4.4.
List of all members, including inherited members
Constructor
Methods
Returns a pointer to source |
|
Retrieves the source raster block column and row corresponding to the specified sorted rank. |
|
Returns the number of valid (non-NoData) sorted cells. |
|
Returns the source raster block index corresponding to the specified sorted rank. |
|
Returns the raster block value corresponding to the specified sorted rank. |
- class qgis.core.QgsSortedRasterBlockIndex[source]¶
Bases:
object- __init__(block: QgsRasterBlock | None)¶
Constructor for QgsSortedRasterBlockIndex, indexing the specified raster
block.Warning
Raster block data is not stored in this class, and the source
QgsRasterBlockmust exist for the lifetime of this object.- Parameters:
block (QgsRasterBlock|None)
- __init__(a0: QgsSortedRasterBlockIndex)
- Parameters:
- block(self) QgsRasterBlock | None[source]¶
Returns a pointer to source
QgsRasterBlock.- Return type:
QgsRasterBlock|None
- sortedColumnRow(self, rank: int, order: Qt.SortOrder = Qt.AscendingOrder)[source]¶
Retrieves the source raster block column and row corresponding to the specified sorted
rank.- Parameters:
rank (int) – Sorted position (0 to
sortedCount()- 1). E.g. 0 for the lowest value, when using an ascending order.order (Qt.SortOrder = Qt.AscendingOrder) – Sort order to query
- Return type:
(int, int)
- Returns:
column: Output column
row: Output row
- sortedCount(self) int[source]¶
Returns the number of valid (non-NoData) sorted cells.
- Return type:
int
- sortedIndex(self, rank: int, order: Qt.SortOrder = Qt.AscendingOrder) int[source]¶
Returns the source raster block index corresponding to the specified sorted
rank.- Parameters:
rank (int) – Sorted position (0 to
sortedCount()- 1). E.g. 0 for the lowest value, when using an ascending order.order (Qt.SortOrder = Qt.AscendingOrder) – Sort order to query
- Return type:
int
- sortedValue(self, rank: int, order: Qt.SortOrder = Qt.AscendingOrder) float[source]¶
Returns the raster block value corresponding to the specified sorted
rank.- Parameters:
rank (int) – Sorted position (0 to
sortedCount()- 1). E.g. 0 for the lowest value, when using an ascending order.order (Qt.SortOrder = Qt.AscendingOrder) – Sort order to query
- Return type:
float