Class: QgsGeometryCollection

class qgis.core.QgsGeometryCollection

Bases: qgis._core.QgsAbstractGeometry

Geometry collection

New in version 2.10: Enums

Methods

addGeometry Adds a geometry and takes ownership.
addMValue
addZValue
adjacentVertices
area
asGml2
asGml3
asJson
asWkb
asWkt
boundary
boundingBox
calculateBoundingBox
childCount
childGeometry
childPoint
clear
clearCache
clone
closestSegment
coordinateSequence
createEmptyWithSameType
deleteVertex
dimension
draw
dropMValue
dropZValue
fromCollectionWkt Reads a collection from a WKT string.
fromWkb
fromWkt
geometryN Returns a geometry from within the collection.
geometryType
hasChildGeometries
hasCurvedSegments
insertGeometry Inserts a geometry before a specified index and takes ownership.
insertVertex
isEmpty
isValid
length
moveVertex
nCoordinates
nextVertex
numGeometries Returns the number of geometries within the collection.
partCount
perimeter
removeDuplicateNodes
removeGeometry Removes a geometry from the collection by index.
ringCount
segmentLength
segmentize Returns a geometry without curves.
setZMTypeFromSubGeometry
snappedToGrid
swapXy
toCurveType
transform transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1)
vertexAngle
vertexAt
vertexCount
vertexNumberFromVertexId
wktOmitChildType Returns whether child type names are omitted from Wkt representations of the collection

Signals

Attributes

addGeometry(self, g: QgsAbstractGeometry) → bool

Adds a geometry and takes ownership. Returns True in case of success.

addMValue(self, mValue: float = 0) → bool
addZValue(self, zValue: float = 0) → bool
adjacentVertices(self, vertex: QgsVertexId) → Tuple[QgsVertexId, QgsVertexId]
area(self) → float
asGml2(self, doc: QDomDocument, precision: int = 17, ns: str = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) → QDomElement
asGml3(self, doc: QDomDocument, precision: int = 17, ns: str = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) → QDomElement
asJson(self, precision: int = 17) → str
asWkb(self) → QByteArray
asWkt(self, precision: int = 17) → str
boundary(self) → QgsAbstractGeometry
boundingBox(self) → QgsRectangle
calculateBoundingBox(self) → QgsRectangle
childCount(self) → int
childGeometry(self, index: int) → QgsAbstractGeometry
childPoint()
clear(self)
clearCache(self)
clone(self) → QgsGeometryCollection
closestSegment(self, pt: QgsPoint, epsilon: float = 4*DBL_EPSILON) → Tuple[float, QgsPoint, QgsVertexId, int]
coordinateSequence(self) → object
createEmptyWithSameType(self) → QgsGeometryCollection
deleteVertex(self, position: QgsVertexId) → bool
dimension(self) → int
draw(self, p: QPainter)
dropMValue(self) → bool
dropZValue(self) → bool
fromCollectionWkt(self, wkt: str, subtypes: object, defaultChildWkbType: str = '') → bool

Reads a collection from a WKT string.

fromWkb(self, wkb: QgsConstWkbPtr) → bool
fromWkt(self, wkt: str) → bool
geometryN(self, n: int) → QgsAbstractGeometry

Returns a geometry from within the collection.

Parameters:n – index of geometry to return. An IndexError will be raised if no geometry with the specified index exists.
geometryType(self) → str
hasChildGeometries()
hasCurvedSegments(self) → bool
insertGeometry(self, g: QgsAbstractGeometry, index: int) → bool

Inserts a geometry before a specified index and takes ownership. Returns True in case of success.

Parameters:
  • g – geometry to insert. Ownership is transferred to the collection.
  • index – position to insert geometry before
insertVertex(self, position: QgsVertexId, vertex: QgsPoint) → bool
isEmpty(self) → bool
isValid(self, flags: int = 0) → Tuple[bool, str]
length(self) → float
moveVertex(self, position: QgsVertexId, newPos: QgsPoint) → bool
nCoordinates(self) → int
nextVertex(self, id: QgsVertexId) → Tuple[bool, QgsPoint]
numGeometries(self) → int

Returns the number of geometries within the collection.

partCount(self) → int
perimeter(self) → float
removeDuplicateNodes(self, epsilon: float = 4*DBL_EPSILON, useZValues: bool = False) → bool
removeGeometry(self, nr: int) → bool

Removes a geometry from the collection by index.

An IndexError will be raised if no geometry with the specified index exists.

Returns:True if removal was successful.
ringCount(self, part: int = 0) → int
segmentLength(self, startVertex: QgsVertexId) → float
segmentize(self, tolerance: float = M_PI_2/90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) → QgsAbstractGeometry

Returns a geometry without curves. Caller takes ownership

Parameters:
  • tolerance – segmentation tolerance
  • toleranceType – maximum segmentation angle or maximum difference between approximation and curve*
setZMTypeFromSubGeometry()
snappedToGrid(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) → QgsGeometryCollection
swapXy(self)
toCurveType(self) → QgsGeometryCollection
transform(self, ct: QgsCoordinateTransform, d: QgsCoordinateTransform.TransformDirection = QgsCoordinateTransform.ForwardTransform, transformZ: bool = False)

transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1)

vertexAngle(self, vertex: QgsVertexId) → float
vertexAt(self, id: QgsVertexId) → QgsPoint
vertexCount(self, part: int = 0, ring: int = 0) → int
vertexNumberFromVertexId(self, id: QgsVertexId) → int
wktOmitChildType(self) → bool

Returns whether child type names are omitted from Wkt representations of the collection

New in version 2.12.