QGIS/python/PyQt6/analysis/auto_generated/vector/qgszonalstatistics.sip.in

160 lines
5.4 KiB
Plaintext
Raw Normal View History

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgszonalstatistics.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl 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:
enum class Statistic /BaseType=IntFlag/
{
Count,
Sum,
Mean,
Median,
StDev,
Min,
Max,
Range,
Minority,
Majority,
Variety,
Variance,
All,
Default,
};
typedef QFlags<QgsZonalStatistics::Statistic> Statistics;
enum Result
{
Success,
LayerTypeWrong,
LayerInvalid,
RasterInvalid,
RasterBandInvalid,
FailedToCreateField,
Canceled
};
QgsZonalStatistics( QgsVectorLayer *polygonLayer,
QgsRasterLayer *rasterLayer,
const QString &attributePrefix = QString(),
int rasterBand = 1,
QgsZonalStatistics::Statistics stats = QgsZonalStatistics::Statistic::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,
QgsZonalStatistics::Statistics stats = QgsZonalStatistics::Statistic::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
QgsZonalStatistics::Result calculateStatistics( QgsFeedback *feedback );
%Docstring
Runs the calculation.
%End
static QString displayName( QgsZonalStatistics::Statistic statistic );
%Docstring
Returns the friendly display name for a ``statistic``.
.. seealso:: :py:func:`shortName`
.. versionadded:: 3.12
%End
static QString shortName( QgsZonalStatistics::Statistic 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, QgsZonalStatistics::Statistics 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:
};
QFlags<QgsZonalStatistics::Statistic> operator|(QgsZonalStatistics::Statistic f1, QFlags<QgsZonalStatistics::Statistic> f2);
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgszonalstatistics.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/