Class: QgsProcessingFeatureSource

class qgis.core.QgsProcessingFeatureSource

Bases: QgsFeatureSource

QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.

New in version 3.0.

QgsProcessingFeatureSource(originalSource: QgsFeatureSource, context: QgsProcessingContext, ownsOriginalSource: bool = False, featureLimit: int = -1, filterExpression: str = ‘’) Constructor for QgsProcessingFeatureSource, accepting an original feature source originalSource and processing context. Ownership of originalSource is dictated by ownsOriginalSource. If ownsOriginalSource is False, ownership is not transferred, and callers must ensure that originalSource exists for the lifetime of this object. If ownsOriginalSource is True, then this object will take ownership of originalSource.

If featureLimit is set to a value > 0, then a limit is placed on the maximum number of features which will be read from the source.

Since QGIS 3.32, the optional filterExpression can be used to specify an expression based filter for the source.

QgsProcessingFeatureSource(QgsProcessingFeatureSource)

Methods

allFeatureIds

rtype:

object

createExpressionContextScope

Returns an expression context scope suitable for this source.

featureCount

rtype:

int

fields

rtype:

QgsFields

getFeatures

Returns an iterator for the features in the source, respecting the supplied feature flags.

hasFeatures

rtype:

QgsFeatureSource.FeatureAvailability

hasSpatialIndex

rtype:

QgsFeatureSource.SpatialIndexPresence

invalidGeometryCheck

Returns the geometry check method for the source.

maximumValue

param fieldIndex:

minimumValue

param fieldIndex:

setInvalidGeometryCheck

Overrides the default geometry check method for the source.

sourceCrs

rtype:

QgsCoordinateReferenceSystem

sourceExtent

rtype:

QgsRectangle

sourceName

rtype:

str

uniqueValues

param fieldIndex:

wkbType

rtype:

Qgis.WkbType

Attributes

FlagSkipGeometryValidityChecks

class Flag

Bases: int

FlagSkipGeometryValidityChecks = 2
class Flags
class Flags(Union[QgsProcessingFeatureSource.Flags, QgsProcessingFeatureSource.Flag])
class Flags(QgsProcessingFeatureSource.Flags)

Bases: sip.wrapper

allFeatureIds(self) object
Return type:

object

createExpressionContextScope(self) QgsExpressionContextScope

Returns an expression context scope suitable for this source.

Return type:

QgsExpressionContextScope

featureCount(self) int
Return type:

int

fields(self) QgsFields
Return type:

QgsFields

getFeatures(self, request: QgsFeatureRequest, flags: QgsProcessingFeatureSource.Flags | QgsProcessingFeatureSource.Flag) QgsFeatureIterator

Returns an iterator for the features in the source, respecting the supplied feature flags. An optional request can be used to optimise the returned iterator, eg by restricting the returned attributes or geometry.

getFeatures(self, request: QgsFeatureRequest = QgsFeatureRequest()) -> QgsFeatureIterator

Parameters:
Return type:

QgsFeatureIterator

hasFeatures(self) QgsFeatureSource.FeatureAvailability
Return type:

QgsFeatureSource.FeatureAvailability

hasSpatialIndex(self) QgsFeatureSource.SpatialIndexPresence
Return type:

QgsFeatureSource.SpatialIndexPresence

invalidGeometryCheck(self) QgsFeatureRequest.InvalidGeometryCheck

Returns the geometry check method for the source.

New in version 3.36.

Return type:

QgsFeatureRequest.InvalidGeometryCheck

maximumValue(self, fieldIndex: int) Any
Parameters:

fieldIndex (int) –

Return type:

Any

minimumValue(self, fieldIndex: int) Any
Parameters:

fieldIndex (int) –

Return type:

Any

setInvalidGeometryCheck(self, method: QgsFeatureRequest.InvalidGeometryCheck)

Overrides the default geometry check method for the source.

New in version 3.14.

Parameters:

method (QgsFeatureRequest.InvalidGeometryCheck) –

sourceCrs(self) QgsCoordinateReferenceSystem
Return type:

QgsCoordinateReferenceSystem

sourceExtent(self) QgsRectangle
Return type:

QgsRectangle

sourceName(self) str
Return type:

str

uniqueValues(self, fieldIndex: int, limit: int = -1) Set[Any]
Parameters:
  • fieldIndex (int) –

  • limit (int = -1) –

Return type:

Set[Any]

wkbType(self) Qgis.WkbType
Return type:

Qgis.WkbType