1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgszonalstatistics.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsZonalStatistics
{
%Docstring(signature="appended")
A class that calculates raster statistics (count, sum, mean) for a
polygon or multipolygon layer and appends the results as attributes.
%End
%TypeHeaderCode
#include "qgszonalstatistics.h"
%End
public:
QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, const QString &attributePrefix = QString(), int rasterBand = 1, Qgis::ZonalStatistics stats = Qgis::ZonalStatistic::Default );
%Docstring
Convenience constructor for QgsZonalStatistics, using an input raster
layer.
The raster layer must exist for the lifetime of the zonal statistics
calculation.
.. warning::
Constructing QgsZonalStatistics using this method is not thread safe, and
the constructor which accepts a :py:class:`QgsRasterInterface` should be used instead.
%End
QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterInterface *rasterInterface, const QgsCoordinateReferenceSystem &rasterCrs, double rasterUnitsPerPixelX, double rasterUnitsPerPixelY, const QString &attributePrefix = QString(), int rasterBand = 1, Qgis::ZonalStatistics stats = Qgis::ZonalStatistic::Default );
%Docstring
Constructor for QgsZonalStatistics, using a QgsRasterInterface.
The ``polygonLayer`` gives the vector layer containing the
(multi)polygon features corresponding to the different zones. This layer
will be modified, adding extra attributes for each of the zonal
statistics calculated.
Pixel values for each zone are taken from the raster
``rasterInterface``. The constructor must also be given various
properties relating to the input raster, such as the raster CRS
(``rasterCrs``), and the size (X and Y) in map units for each raster
pixel. The source raster band is specified via ``rasterBand``, where a
value of 1 corresponds to the first band.
If the CRS of the ``polygonLayer`` and ``rasterCrs`` differ, the
calculation will automatically reproject the zones to ensure valid
results are calculated.
The ``attributePrefix`` argument specifies an optional prefix to use
when creating the new fields for each calculated statistic.
Finally, the calculated statistics can be set via the ``stats``
argument. A new field will be added to ``polygonLayer`` for each
statistic calculated.
.. warning::
The raster interface must exist for the lifetime of the zonal statistics calculation. For thread
safe use, always use a cloned raster interface.
.. versionadded:: 3.2
%End
Qgis::ZonalStatisticResult calculateStatistics( QgsFeedback *feedback );
%Docstring
Runs the calculation.
%End
static QString displayName( Qgis::ZonalStatistic statistic );
%Docstring
Returns the friendly display name for a ``statistic``.
.. seealso:: :py:func:`shortName`
.. versionadded:: 3.12
%End
static QString shortName( Qgis::ZonalStatistic statistic );
%Docstring
Returns a short, friendly display name for a ``statistic``, suitable for
use in a field name.
.. seealso:: :py:func:`displayName`
.. versionadded:: 3.12
%End
static QMap<int, QVariant> calculateStatisticsInt( QgsRasterInterface *rasterInterface, const QgsGeometry &geometry, double cellSizeX, double cellSizeY, int rasterBand, Qgis::ZonalStatistics statistics ) /PyName=calculateStatistics/;
%Docstring
Calculates the specified ``statistics`` for the pixels of ``rasterBand``
in ``rasterInterface`` (a raster layer
:py:func:`~QgsZonalStatistics.dataProvider` ) within polygon
``geometry``.
Returns a map of statistic to result value.
.. versionadded:: 3.16
%End
public:
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgszonalstatistics.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|