23QString QgsZonalMinimumMaximumPointAlgorithm::name()
const
25 return QStringLiteral(
"zonalminmaxpoint" );
28QString QgsZonalMinimumMaximumPointAlgorithm::displayName()
const
30 return QObject::tr(
"Zonal minimum/maximum point" );
33QStringList QgsZonalMinimumMaximumPointAlgorithm::tags()
const
35 return QObject::tr(
"stats,statistics,zones,maximum,minimum,raster,extrema,extremum" ).split(
',' );
38QString QgsZonalMinimumMaximumPointAlgorithm::group()
const
40 return QObject::tr(
"Raster analysis" );
43QString QgsZonalMinimumMaximumPointAlgorithm::groupId()
const
45 return QStringLiteral(
"rasteranalysis" );
48QString QgsZonalMinimumMaximumPointAlgorithm::shortDescription()
const
50 return QObject::tr(
"Extracts point locations for minimum and maximum raster values within polygon zones." );
53QString QgsZonalMinimumMaximumPointAlgorithm::shortHelpString()
const
55 return QObject::tr(
"This algorithm extracts point features corresponding to the minimum "
56 "and maximum pixel values contained within polygon zones.\n\n"
57 "The output will contain one point feature for the minimum and one "
58 "for the maximum raster value for every individual zonal feature "
59 "from a polygon layer.\n\n"
60 "The created point layer will be in the same spatial reference system as the selected raster layer." );
63QList<int> QgsZonalMinimumMaximumPointAlgorithm::inputLayerTypes()
const
68QgsZonalMinimumMaximumPointAlgorithm *QgsZonalMinimumMaximumPointAlgorithm::createInstance()
const
70 return new QgsZonalMinimumMaximumPointAlgorithm();
73void QgsZonalMinimumMaximumPointAlgorithm::initParameters(
const QVariantMap &configuration )
75 Q_UNUSED( configuration )
78 QObject::tr(
"Raster band" ), 1, QStringLiteral(
"INPUT_RASTER" ) ) );
81QString QgsZonalMinimumMaximumPointAlgorithm::outputName()
const
83 return QObject::tr(
"Zonal Extrema" );
86QgsFields QgsZonalMinimumMaximumPointAlgorithm::outputFields(
const QgsFields &inputFields )
const
88 Q_UNUSED( inputFields )
119 QgsRasterLayer *rasterLayer = parameterAsRasterLayer( parameters, QStringLiteral(
"INPUT_RASTER" ), context );
123 mBand = parameterAsInt( parameters, QStringLiteral(
"RASTER_BAND" ), context );
124 if ( mBand < 1 || mBand > rasterLayer->
bandCount() )
125 throw QgsProcessingException( QObject::tr(
"Invalid band number for BAND (%1): Valid values for input raster are 1 to %2" ).arg( mBand )
129 throw QgsProcessingException( QObject::tr(
"Invalid raster layer. Layer %1 is invalid." ).arg( rasterLayer->
id() ) );
132 mCrs = rasterLayer->
crs();
135 std::unique_ptr<QgsFeatureSource> source( parameterAsSource( parameters, inputParameterName(), context ) );
138 newFields.
append(
QgsField( QStringLiteral(
"value" ), QMetaType::Type::Double, QString(), 20, 8 ) );
139 newFields.
append(
QgsField( QStringLiteral(
"extremum_type" ), QMetaType::Type::QString ) );
147 if ( !mCreatedTransform )
149 mCreatedTransform =
true;
159 geometry.
transform( mFeatureToRasterTransform );
164 feedback->
reportError( QObject::tr(
"Encountered a transform error when reprojecting feature with id %1." ).arg( feature.
id() ) );
173 minPointFeature.setAttributes( minAttributes );
179 maxPointFeature.setAttributes( maxAttributes );
185bool QgsZonalMinimumMaximumPointAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
ProcessingSourceType
Processing data source types.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ Max
Max of pixel values.
@ MinimumPoint
Pixel centroid for minimum pixel value.
@ Min
Min of pixel values.
@ MaximumPoint
Pixel centroid for maximum pixel value.
@ RegeneratesPrimaryKey
Algorithm always drops any existing primary keys or FID values and regenerates them in outputs.
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
WkbType
The WKB type describes the number of dimensions a geometry has.
This class represents a coordinate reference system (CRS).
Custom exception class for Coordinate Reference System related exceptions.
QFlags< SinkFlag > SinkFlags
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
Base class for all map layer types.
QgsCoordinateReferenceSystem crs
A class to represent a 2D point.
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A raster band parameter for Processing algorithms.
A raster layer parameter for processing algorithms.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
QgsRasterDataProvider * clone() const override=0
Clone itself, create deep copy.
Represents a raster layer.
int bandCount() const
Returns the number of bands in this layer.
double rasterUnitsPerPixelX() const
Returns the number of raster units per each raster pixel in X axis.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
double rasterUnitsPerPixelY() const
Returns the number of raster units per each raster pixel in Y axis.
Qgis::ZonalStatisticResult calculateStatistics(QgsFeedback *feedback)
Runs the calculation.
QList< QgsFeature > QgsFeatureList