Class: QgsVectorLayerExporter¶
A convenience class for exporting vector layers to a destination data provider.
QgsVectorLayerExporter
can be used in two ways:
Using a static call to
QgsVectorLayerExporter
.exportLayer(…) which exports the entire layer to the destination provider.Create an instance of the class and issue calls to addFeature(…)
Class Hierarchy¶
Base classes¶
An interface for objects which accept features via addFeature(s) methods. |
Enums
alias of |
Methods
Returns the attribute capabilities of the exporter. |
|
Returns any encountered error code, or |
|
Returns the number of error messages encountered during the export. |
|
Returns any error message encountered during the export. |
Static Methods
Writes the contents of vector layer to a different datasource. |
- class qgis.core.QgsVectorLayerExporter[source]¶
Bases:
QgsFeatureSink
- __init__(uri: str | None, provider: str | None, fields: QgsFields, geometryType: Qgis.WkbType, crs: QgsCoordinateReferenceSystem, overwrite: bool = False, options: Dict[str | None, Any] = {}, sinkFlags: QgsFeatureSink.SinkFlags | QgsFeatureSink.SinkFlag = QgsFeatureSink.SinkFlags())
Constructor for QgsVectorLayerExporter.
- Parameters:
uri (Optional[str]) – URI for destination data source
provider (Optional[str]) – string key for destination data provider
fields (QgsFields) – fields to include in created layer
geometryType (Qgis.WkbType) – destination geometry type
crs (QgsCoordinateReferenceSystem) – desired CRS, or an invalid (default constructed) CRS if not available
overwrite (bool = False) – set to
True
to overwrite any existing data sourceoptions (Dict[Optional[str], Any] = {}) – optional provider dataset options
sinkFlags (Union[QgsFeatureSink.SinkFlags, QgsFeatureSink.SinkFlag] = QgsFeatureSink.SinkFlags()) – for how to add features
- ExportError¶
alias of
VectorExportResult
- attributeEditCapabilities(self) Qgis.VectorDataProviderAttributeEditCapabilities [source]¶
Returns the attribute capabilities of the exporter.
Added in version 3.32.
- Return type:
- errorCode(self) Qgis.VectorExportResult [source]¶
Returns any encountered error code, or
False
if no error was encountered.See also
See also
- Return type:
- errorCount(self) int [source]¶
Returns the number of error messages encountered during the export.
See also
See also
- Return type:
int
- errorMessage(self) str [source]¶
Returns any error message encountered during the export.
See also
See also
- Return type:
str
- static exportLayer(layer: QgsVectorLayer | None, uri: str | None, providerKey: str | None, destCRS: QgsCoordinateReferenceSystem, onlySelected: bool = False, options: Dict[str | None, Any] = {}, feedback: QgsFeedback | None = None)[source]¶
Writes the contents of vector layer to a different datasource.
- Parameters:
layer (Optional[QgsVectorLayer]) – source layer
uri (Optional[str]) – URI for destination data source
providerKey (Optional[str]) – string key for destination data provider
destCRS (QgsCoordinateReferenceSystem) – destination CRS, or an invalid (default constructed) CRS if not available
onlySelected (bool = False) – set to
True
to export only selected featuresoptions (Dict[Optional[str], Any] = {}) – optional provider dataset options
feedback (Optional[QgsFeedback] = None) -> (Qgis.VectorExportResult) – optional feedback object to show progress and cancellation of export
- Returns:
NoError for a successful export, or encountered error
errorMessage: if non-null, any error messages