Class: QgsPolygon

class qgis.core.QgsPolygon

Bases: QgsCurvePolygon

Polygon geometry type.

New in version 2.10.

QgsPolygon() Constructor for an empty polygon geometry.

QgsPolygon(exterior: QgsLineString, rings: Iterable[QgsLineString] = []) Constructor for QgsPolygon, with the specified exterior ring and interior rings.

Ownership of exterior and rings is transferred to the polygon.

New in version 3.14.

QgsPolygon(QgsPolygon)

Methods

addInteriorRing

param ring

asWkb

param flags

boundary

rtype

QgsAbstractGeometry

clear

clone

rtype

QgsPolygon

createEmptyWithSameType

rtype

QgsPolygon

fromWkb

param wkb

geometryType

rtype

str

pointDistanceToBoundary

Returns the distance from a point to the boundary of the polygon (either the exterior ring or any closer interior rings).

setExteriorRing

param ring

surfaceToPolygon

rtype

QgsPolygon

toCurveType

Returns the geometry converted to the more generic curve type QgsCurvePolygon

wkbSize

param flags

addInteriorRing(self, ring: QgsCurve)
Parameters

ring (QgsCurve) –

asWkb(self, flags: Union[QgsAbstractGeometry.WkbFlags, QgsAbstractGeometry.WkbFlag] = QgsAbstractGeometry.WkbFlags()) QByteArray
Parameters

flags (Union[QgsAbstractGeometry.WkbFlags) –

Return type

QByteArray

boundary(self) QgsAbstractGeometry
Return type

QgsAbstractGeometry

clear(self)
clone(self) QgsPolygon
Return type

QgsPolygon

createEmptyWithSameType(self) QgsPolygon
Return type

QgsPolygon

fromWkb(self, wkb: QgsConstWkbPtr) bool
Parameters

wkb (QgsConstWkbPtr) –

Return type

bool

geometryType(self) str
Return type

str

pointDistanceToBoundary(self, x: float, y: float) float

Returns the distance from a point to the boundary of the polygon (either the exterior ring or any closer interior rings). The returned distance will be negative if the point lies outside the polygon.

New in version 3.0.

Parameters
  • x (float) –

  • y (float) –

Return type

float

setExteriorRing(self, ring: QgsCurve)
Parameters

ring (QgsCurve) –

surfaceToPolygon(self) QgsPolygon
Return type

QgsPolygon

toCurveType(self) QgsCurvePolygon

Returns the geometry converted to the more generic curve type QgsCurvePolygon

Return type

QgsCurvePolygon

Returns

the converted geometry. Caller takes ownership

wkbSize(self, flags: Union[QgsAbstractGeometry.WkbFlags, QgsAbstractGeometry.WkbFlag] = QgsAbstractGeometry.WkbFlags()) int
Parameters

flags (Union[QgsAbstractGeometry.WkbFlags) –

Return type

int