Class: QgsMultiPolygon

class qgis.core.QgsMultiPolygon

Bases: QgsMultiSurface

Multi polygon geometry collection.

QgsMultiPolygon() Constructor for an empty multipolygon geometry.

QgsMultiPolygon(polygons: Iterable[QgsPolygon]) Constructor for a multipolygon containing the specified polygons.

The polygons will be internally cloned.

Added in version 3.38.

QgsMultiPolygon(polygons: Iterable[QgsPolygon]) Constructor for a multipolygon containing the specified polygons.

Ownership of the polygons will be transferred to the multipolygon.

Added in version 3.38.

QgsMultiPolygon(a0: QgsMultiPolygon)

Methods

addGeometries

param geometries:

addGeometry

param g:

asGml2

param doc:

asGml3

param doc:

boundary

rtype:

Optional[QgsAbstractGeometry]

calculateBoundingBox

Default calculator for the minimal bounding box for the geometry.

calculateBoundingBox3D

childCount

childGeometry

childPoint

Returns point at index (for geometries without child geometries - i.e. curve / point).

clear

clearCache

clone

rtype:

Optional[QgsMultiPolygon]

compareToSameClass

createEmptyWithSameType

rtype:

Optional[QgsMultiPolygon]

fromCollectionWkt

Reads a collection from a WKT string.

fromWkt

param wkt:

geometryType

rtype:

str

hasChildGeometries

Returns whether the geometry has any child geometries (False for point / curve, True otherwise)

insertGeometry

param g:

polygonN

Returns the polygon with the specified index.

setZMTypeFromSubGeometry

Updates the geometry type based on whether sub geometries contain z or m values.

simplifyByDistance

param tolerance:

sortIndex

Returns the sort index for the geometry, used in the compareTo() method to compare geometries of different types.

toCurveType

Returns the geometry converted to the more generic curve type QgsMultiSurface

wktOmitChildType

rtype:

bool

addGeometries(self, geometries: Iterable[QgsAbstractGeometry]) bool
Parameters:

geometries (Iterable[QgsAbstractGeometry])

Return type:

bool

addGeometry(self, g: QgsAbstractGeometry | None) bool
Parameters:

g (Optional[QgsAbstractGeometry])

Return type:

bool

asGml2(self, doc: QDomDocument, precision: int = 17, ns: str | None = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement
Parameters:
  • doc (QDomDocument)

  • precision (int = 17)

  • ns (Optional[str] = '')

  • axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY)

Return type:

QDomElement

asGml3(self, doc: QDomDocument, precision: int = 17, ns: str | None = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement
Parameters:
  • doc (QDomDocument)

  • precision (int = 17)

  • ns (Optional[str] = '')

  • axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY)

Return type:

QDomElement

boundary(self) QgsAbstractGeometry | None
Return type:

Optional[QgsAbstractGeometry]

calculateBoundingBox(self) QgsRectangle

Default calculator for the minimal bounding box for the geometry. Derived classes should override this method if a more efficient bounding box calculation is available.

calculateBoundingBox3D(self) QgsBox3D
childCount(self) int
childGeometry(self, index: int) QgsAbstractGeometry | None
childPoint(self, index: int) QgsPoint

Returns point at index (for geometries without child geometries - i.e. curve / point)

Note

used for vertex_iterator implementation

clear(self)
clearCache(self)
clone(self) QgsMultiPolygon | None
Return type:

Optional[QgsMultiPolygon]

compareToSameClass(self, other: QgsAbstractGeometry | None) int
createEmptyWithSameType(self) QgsMultiPolygon | None
Return type:

Optional[QgsMultiPolygon]

fromCollectionWkt(self, wkt: str | None, subtypes: Iterable[QgsAbstractGeometry], defaultChildWkbType: str | None = '') bool

Reads a collection from a WKT string.

fromWkt(self, wkt: str | None) bool
Parameters:

wkt (Optional[str])

Return type:

bool

geometryType(self) str
Return type:

str

hasChildGeometries(self) bool

Returns whether the geometry has any child geometries (False for point / curve, True otherwise)

Note

used for vertex_iterator implementation

insertGeometry(self, g: QgsAbstractGeometry | None, index: int) bool
Parameters:
Return type:

bool

polygonN(self, index: int) QgsPolygon

Returns the polygon with the specified index.

Raises:

IndexError – if no polygon with the specified index exists.

Added in version 3.16.

Parameters:

index (int)

Return type:

QgsPolygon

setZMTypeFromSubGeometry(self, subggeom: QgsAbstractGeometry | None, baseGeomType: Qgis.WkbType)

Updates the geometry type based on whether sub geometries contain z or m values.

simplifyByDistance(self, tolerance: float) QgsMultiPolygon | None
Parameters:

tolerance (float)

Return type:

Optional[QgsMultiPolygon]

sortIndex(self) int

Returns the sort index for the geometry, used in the compareTo() method to compare geometries of different types.

Added in version 3.20.

toCurveType(self) QgsMultiSurface | None

Returns the geometry converted to the more generic curve type QgsMultiSurface

Return type:

Optional[QgsMultiSurface]

Returns:

the converted geometry. Caller takes ownership

wktOmitChildType(self) bool
Return type:

bool