Class: QgsFeatureSink

An interface for objects which accept features via addFeature(s) methods.

Class Hierarchy

Inheritance diagram of qgis.core.QgsFeatureSink

Subclasses

QgsVectorLayer

Represents a vector layer which manages a vector based data sets.

QgsFeatureStore

A container for features with the same fields and crs.

QgsProxyFeatureSink

A simple feature sink which proxies feature addition on to another feature sink.

QgsRemappingProxyFeatureSink

A QgsFeatureSink which proxies incoming features to a destination feature sink, after applying transformations and field value mappings.

QgsSpatialIndex

A spatial index for QgsFeature objects.

QgsVectorDataProvider

This is the base class for vector data providers.

QgsVectorFileWriter

A convenience class for writing vector layers to disk based formats (e.g. Shapefiles, GeoPackage).

QgsVectorLayerExporter

A convenience class for exporting vector layers to a destination data provider.

QgsVectorLayerJoinBuffer

Manages joined fields for a vector layer.

QgsFeaturePool

A feature pool is based on a vector layer and caches features.

Methods

addFeature

Adds a single feature to the sink.

addFeatures

Adds a list of features to the sink.

flushBuffer

Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.

lastError

Returns the most recent error encountered by the sink, e.g. when a call to addFeatures() returns False.

Attributes

FastInsert

RegeneratePrimaryKey

RollBackOnErrors

class qgis.core.QgsFeatureSink[source]

Bases: object

FastInsert = 2
class Flag

Bases: int

class Flags
class Flags(f: QgsFeatureSink.Flags | QgsFeatureSink.Flag)
class Flags(a0: QgsFeatureSink.Flags)

Bases: object

RegeneratePrimaryKey = 2
RollBackOnErrors = 4
class SinkFlag

Bases: int

class SinkFlags
class SinkFlags(f: QgsFeatureSink.SinkFlags | QgsFeatureSink.SinkFlag)
class SinkFlags(a0: QgsFeatureSink.SinkFlags)

Bases: object

addFeature(self, feature: QgsFeature, flags: QgsFeatureSink.Flags | QgsFeatureSink.Flag = QgsFeatureSink.Flags()) bool[source]

Adds a single feature to the sink. Feature addition behavior is controlled by the specified flags.

See also

addFeatures()

Return type:

bool

Returns:

True in case of success and False in case of failure

Parameters:
addFeatures(self, features: Iterable[QgsFeature], flags: QgsFeatureSink.Flags | QgsFeatureSink.Flag = QgsFeatureSink.Flags()) bool[source]

Adds a list of features to the sink. Feature addition behavior is controlled by the specified flags.

See also

addFeature()

Return type:

bool

Returns:

True in case of success and False in case of failure

Parameters:
addFeatures(self, iterator: QgsFeatureIterator, flags: QgsFeatureSink.Flags | QgsFeatureSink.Flag = QgsFeatureSink.Flags()) bool[source]

Adds all features from the specified iterator to the sink. Feature addition behavior is controlled by the specified flags.

Return type:

bool

Returns:

True if all features were added successfully, or False if any feature could not be added

Parameters:
flushBuffer(self) bool[source]

Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink’s destination.

Return type:

bool

Returns:

False if any buffered features could not be added to the sink.

lastError(self) str[source]

Returns the most recent error encountered by the sink, e.g. when a call to addFeatures() returns False.

Added in version 3.16.

Return type:

str