Class: QgsPolygon

Polygon geometry type.

Class Hierarchy

Inheritance diagram of qgis.core.QgsPolygon

Base classes

QgsCurvePolygon

Curve polygon geometry type

QgsSurface

Surface geometry type.

QgsAbstractGeometry

Abstract base class for all geometries

Subclasses

QgsTriangle

Triangle geometry type.

Methods

pointDistanceToBoundary

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

toCurveType

Returns the geometry converted to the more generic curve type QgsCurvePolygon

class qgis.core.QgsPolygon[source]

Bases: QgsCurvePolygon

__init__()

Constructor for an empty polygon geometry.

__init__(exterior: QgsLineString | None, rings: Iterable[QgsLineString] = [])

Constructor for QgsPolygon, with the specified exterior ring and interior rings.

Ownership of exterior and rings is transferred to the polygon.

Added in version 3.14.

Parameters:
__init__(a0: QgsPolygon)
Parameters:

a0 (QgsPolygon)

pointDistanceToBoundary(self, x: float, y: float) float[source]

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.

Parameters:
  • x (float)

  • y (float)

Return type:

float

toCurveType(self) QgsCurvePolygon | None[source]

Returns the geometry converted to the more generic curve type QgsCurvePolygon

Return type:

Optional[QgsCurvePolygon]

Returns:

the converted geometry. Caller takes ownership