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 )
77 addParameter(
new QgsProcessingParameterBand( QStringLiteral(
"RASTER_BAND" ), QObject::tr(
"Raster band" ), 1, QStringLiteral(
"INPUT_RASTER" ) ) );
80QString QgsZonalMinimumMaximumPointAlgorithm::outputName()
const
82 return QObject::tr(
"Zonal Extrema" );
85QgsFields QgsZonalMinimumMaximumPointAlgorithm::outputFields(
const QgsFields &inputFields )
const
87 Q_UNUSED( inputFields )
118 QgsRasterLayer *rasterLayer = parameterAsRasterLayer( parameters, QStringLiteral(
"INPUT_RASTER" ), context );
122 mBand = parameterAsInt( parameters, QStringLiteral(
"RASTER_BAND" ), context );
123 if ( mBand < 1 || mBand > rasterLayer->
bandCount() )
124 throw QgsProcessingException( QObject::tr(
"Invalid band number for BAND (%1): Valid values for input raster are 1 to %2" ).arg( mBand ).arg( rasterLayer->
bandCount() ) );
127 throw QgsProcessingException( QObject::tr(
"Invalid raster layer. Layer %1 is invalid." ).arg( rasterLayer->
id() ) );
130 mCrs = rasterLayer->
crs();
133 std::unique_ptr<QgsFeatureSource> source( parameterAsSource( parameters, inputParameterName(), context ) );
136 newFields.
append(
QgsField( QStringLiteral(
"value" ), QMetaType::Type::Double, QString(), 20, 8 ) );
137 newFields.
append(
QgsField( QStringLiteral(
"extremum_type" ), QMetaType::Type::QString ) );
145 if ( !mCreatedTransform )
147 mCreatedTransform =
true;
157 geometry.
transform( mFeatureToRasterTransform );
162 feedback->
reportError( QObject::tr(
"Encountered a transform error when reprojecting feature with id %1." ).arg( feature.
id() ) );
170 minPointFeature.setAttributes( minAttributes );
176 maxPointFeature.setAttributes( maxAttributes );
182bool 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