Class: QgsVectorLayerEditUtils

class qgis.core.QgsVectorLayerEditUtils(layer: QgsVectorLayer)

Bases: sip.wrapper

QgsVectorLayerEditUtils(QgsVectorLayerEditUtils)

Enums

Methods

addCurvedPart

Adds a new part polygon to a multipart feature

addCurvedRing

Adds a ring to polygon/multipolygon features

addPart

Adds a new part polygon to a multipart feature

addRing

Adds a ring to polygon/multipolygon features

addTopologicalPoints

Adds topological points for every vertex of the geometry.

deleteVertex

Deletes a vertex from a feature.

insertVertex

Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries

moveVertex

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates

moveVertexV2

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates

splitFeatures

Splits features cut by the given line

splitParts

Splits parts cut by the given line

translateFeature

Translates feature by dx, dy

Signals

Attributes

addCurvedPart(self, ring: QgsCurve, featureId: int) → QgsGeometry.OperationResult

Adds a new part polygon to a multipart feature

Returns

  • QgsGeometry.Success

  • QgsGeometry.AddPartSelectedGeometryNotFound

  • QgsGeometry.AddPartNotMultiGeometry

  • QgsGeometry.InvalidBaseGeometry

  • QgsGeometry.InvalidInput

Note

available in python bindings as addCurvedPart

addCurvedRing(self, ring: QgsCurve, targetFeatureIds: object = QgsFeatureIds()) → Tuple[QgsGeometry.OperationResult, int]

Adds a ring to polygon/multipolygon features

Parameters
  • ring – ring to add

  • targetFeatureIds – if specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to the first valid feature.

  • modifiedFeatureId – if specified, feature ID for feature that ring was added to will be stored in this parameter

Returns

OperationResult result code: success or reason of failure

Note

available in python bindings as addCurvedRing

addPart(self, ring: Iterable[QgsPointXY], featureId: int) → QgsGeometry.OperationResult

Adds a new part polygon to a multipart feature

Returns

  • QgsGeometry.Success

  • QgsGeometry.AddPartSelectedGeometryNotFound

  • QgsGeometry.AddPartNotMultiGeometry

  • QgsGeometry.InvalidBaseGeometry

  • QgsGeometry.InvalidInput

addPart(self, ring: Iterable[QgsPoint], featureId: int) -> QgsGeometry.OperationResult Adds a new part polygon to a multipart feature

Returns

  • QgsGeometry.Success

  • QgsGeometry.AddPartSelectedGeometryNotFound

  • QgsGeometry.AddPartNotMultiGeometry

  • QgsGeometry.InvalidBaseGeometry

  • QgsGeometry.InvalidInput

Note

available in python bindings as addPartV2

addRing(self, ring: Iterable[QgsPointXY], targetFeatureIds: object = QgsFeatureIds()) → Tuple[QgsGeometry.OperationResult, int]

Adds a ring to polygon/multipolygon features

Parameters
  • ring – ring to add

  • targetFeatureIds – if specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to the first valid feature.

  • modifiedFeatureId – if specified, feature ID for feature that ring was added to will be stored in this parameter

Returns

OperationResult result code: success or reason of failure

addTopologicalPoints(self, geom: QgsGeometry) → int

Adds topological points for every vertex of the geometry.

Parameters

geom – the geometry where each vertex is added to segments of other features

Returns

0 in case of success

Note

geom is not going to be modified by the function

addTopologicalPoints(self, p: QgsPointXY) -> int Adds a vertex to segments which intersect point p but don’t already have a vertex there. If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Returns

0 in case of success

addTopologicalPoints(self, p: QgsPoint) -> int Adds a vertex to segments which intersect point p but don’t already have a vertex there. If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Returns

0 in case of success

New in version 3.10.

deleteVertex(self, featureId: int, vertex: int) → QgsVectorLayer.EditResult

Deletes a vertex from a feature.

Parameters
  • featureId – ID of feature to remove vertex from

  • vertex – index of vertex to delete

New in version 2.14.

insertVertex(self, x: float, y: float, atFeatureId: int, beforeVertex: int) → bool

Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries

insertVertex(self, point: QgsPoint, atFeatureId: int, beforeVertex: int) -> bool Inserts a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries

moveVertex(self, x: float, y: float, atFeatureId: int, atVertex: int) → bool

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates

moveVertexV2(self, p: QgsPoint, atFeatureId: int, atVertex: int) → bool

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates

Note

available in Python bindings as moveVertexV2

splitFeatures(self, splitLine: Iterable[QgsPointXY], topologicalEditing: bool = False) → QgsGeometry.OperationResult

Splits features cut by the given line

Parameters
  • splitLine – line that splits the layer features

  • topologicalEditingTrue if topological editing is enabled

Returns

0 in case of success, 4 if there is a selection but no feature split

splitParts(self, splitLine: Iterable[QgsPointXY], topologicalEditing: bool = False) → QgsGeometry.OperationResult

Splits parts cut by the given line

Parameters
  • splitLine – line that splits the layer feature parts

  • topologicalEditingTrue if topological editing is enabled

Returns

  • QgsGeometry.InvalidBaseGeometry

  • QgsGeometry.Success

  • QgsGeometry.InvalidInput

  • QgsGeometry.NothingHappened if a selection is present but no feature has been split

  • QgsGeometry.InvalidBaseGeometry

  • QgsGeometry.GeometryEngineError

  • QgsGeometry.SplitCannotSplitPoint

translateFeature(self, featureId: int, dx: float, dy: float) → int

Translates feature by dx, dy

Parameters
  • featureId – id of the feature to translate

  • dx – translation of x-coordinate

  • dy – translation of y-coordinate

Returns

0 in case of success