Contact : ole.moller.nielsen@gmail.com
Note
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Calculate zonal statics given two layers.
Parameters: |
|
---|---|
Returns: | A data structure containing sum, mean, min, max, count of raster values for each polygonal area. |
Return type: | dict |
Raises: | InvalidParameterError, InvalidGeometryError |
Example of output data structure:
- { 1: {‘sum’: 10, ‘count’: 20, ‘min’: 1, ‘max’: 4, ‘mean’: 2},
- 2: {‘sum’: 10, ‘count’: 20, ‘min’: 1, ‘max’: 4, ‘mean’: 2}, 3 {‘sum’: 10, ‘count’: 20, ‘min’: 1, ‘max’: 4, ‘mean’: 2}}
The key in the outer dict is the feature id
Note
This is a python port of the zonal stats implementation in QGIS . See https://github.com/qgis/Quantum-GIS/blob/master/src/analysis/ vector/qgszonalstatistics.cpp
Note
Currently not projection checks are made to ensure that both layers are in the same CRS - we assume they are.
Stats where centroid of each cell must intersect the polygon.
Parameters: |
|
---|---|
Returns: | Sum, Count - sum of the values of all pixels and the count of pixels that intersect with the geometry. |
Return type: | (float, int) |
Calculate cell offset and distances for the intersecting bbox.
Parameters: |
|
---|---|
Returns: | Offsets in the x and y directions, and number of cells in the x and y directions. |
Return type: | (int, int, int, int) |
Invert standard 3x2 set of geo-transform coefficients.
Parameters: |
|
---|
Convert map coordinates to pixel coordinates.
Parameters: |
|
---|
:returns pixel_x, pixel_y - Output pixel coordinates :rtype: (int, int)
Parameters: |
|
---|---|
Returns: | Sum, Count - sum of the values of all pixels and the count of pixels that intersect with the geometry. |
Return type: | (float, int) |
Convert pixel coordinates to map coordinates.
Parameters: |
|
---|
:returns map_x, map_y - Output map coordinates :rtype: (float, float)
Weighted pixel sum for polygon based on only intersecting parts.
Parameters: |
|
---|---|
Returns: | Sum, Count - sum of the values of all pixels and the count of pixels that intersect with the geometry. |
Return type: | (float, int) |
We define a tr() alias here since the utilities implementation.
The code below is not a class and does not inherit from QObject.
Note
Parameters: | text (str) – String to be translated |
---|---|
Returns: | Translated version of the given string if available, otherwise the original string. |
Apply a geo transform to coordinates.
Parameters: |
|
---|
:returns output_x, output_y - Transformed X and Y coordinates :rtype: (float, float)