Class: QgsCurvePolygon

Curve polygon geometry type.

Class Hierarchy

Inheritance diagram of qgis.core.QgsCurvePolygon

Base classes

QgsSurface

Surface geometry type.

QgsAbstractGeometry

Abstract base class for all geometries.

Subclasses

QgsPolygon

Polygon geometry type.

Abstract Methods

vertexAngle

Returns approximate rotation angle for a vertex.

Methods

exteriorRing

Returns the curve polygon's exterior ring.

forceClockwise

Forces the polygon to respect the exterior ring is clockwise, interior rings are counter-clockwise convention.

forceCounterClockwise

Forces the polygon to respect the exterior ring is counter-clockwise, interior rings are clockwise convention.

forceRHR

Forces the geometry to respect the Right-Hand-Rule, in which the area that is bounded by the polygon is to the right of the boundary.

interiorRing

Retrieves an interior ring from the curve polygon.

numInteriorRings

Returns the number of interior rings contained with the curve polygon.

removeInteriorRing

Removes an interior ring from the polygon.

removeInteriorRings

Removes the interior rings from the polygon.

removeInvalidRings

Removes any interior rings which are not valid from the polygon.

roundness

Returns the roundness of the curve polygon.

setInteriorRings

Sets all interior rings (takes ownership)

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsCurvePolygon. See the FAQ for more details.

addInteriorRing

Adds an interior ring to the geometry (takes ownership)

segmentize

Returns a geometry without curves.

setExteriorRing

Sets the exterior ring of the polygon.

surfaceToPolygon

Gets a polygon representation of this surface.

toPolygon

Returns a new polygon geometry corresponding to a segmentized approximation of the curve.

class qgis.core.QgsCurvePolygon[source]

Bases: QgsSurface

virtual addInteriorRing(self, ring: QgsCurve | None)[source]

Adds an interior ring to the geometry (takes ownership)

Parameters:

ring (Optional[QgsCurve])

exteriorRing(self) QgsCurve | None[source]

Returns the curve polygon’s exterior ring.

See also

interiorRing()

Return type:

Optional[QgsCurve]

forceClockwise(self)[source]

Forces the polygon to respect the exterior ring is clockwise, interior rings are counter-clockwise convention.

This convention is used primarily by ESRI software.

Added in version 3.24.

forceCounterClockwise(self)[source]

Forces the polygon to respect the exterior ring is counter-clockwise, interior rings are clockwise convention.

This convention matches the OGC Simple Features specification.

See also

forceClockwise()

Added in version 3.24.

forceRHR(self)[source]

Forces the geometry to respect the Right-Hand-Rule, in which the area that is bounded by the polygon is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.

Warning

Due to the conflicting definitions of the right-hand-rule in general use, it is recommended to use the explicit forceClockwise() or forceCounterClockwise() methods instead.

See also

forceClockwise()

Added in version 3.6.

interiorRing(self, i: int) QgsCurve[source]

Retrieves an interior ring from the curve polygon. The first interior ring has index 0.

Raises:

IndexError – if no interior ring with the specified index exists.

See also

exteriorRing()

Parameters:

i (int)

Return type:

QgsCurve

numInteriorRings(self) int[source]

Returns the number of interior rings contained with the curve polygon.

See also

interiorRing()

Return type:

int

removeInteriorRing(self, i: int) bool[source]

Removes an interior ring from the polygon. The first interior ring has index 0. The corresponding ring is removed from the polygon and deleted. It is not possible to remove the exterior ring using this method.

Raises:

IndexError – if no interior ring with the specified index exists.

Parameters:

i (int)

Return type:

bool

removeInteriorRings(self, minimumAllowedArea: float = -1)[source]

Removes the interior rings from the polygon. If the minimumAllowedArea parameter is specified then only rings smaller than this minimum area will be removed.

Parameters:

minimumAllowedArea (float = -1)

removeInvalidRings(self)[source]

Removes any interior rings which are not valid from the polygon.

For example, this removes unclosed rings and rings with less than 4 vertices.

roundness(self) float[source]

Returns the roundness of the curve polygon. The returned value is between 0 and 1.

Added in version 3.24.

Return type:

float

virtual segmentize(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsAbstractGeometry | None[source]

Returns a geometry without curves. Caller takes ownership

Parameters:
  • tolerance (float = M_PI_2/90) – segmentation tolerance

  • toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve

Return type:

Optional[QgsAbstractGeometry]

virtual setExteriorRing(self, ring: QgsCurve | None)[source]

Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality of the exterior ring. For instance, setting a 2D exterior ring on a 3D CurvePolygon will drop the z dimension from the CurvePolygon and all interior rings.

Parameters:

ring (Optional[QgsCurve]) – new exterior ring. Ownership is transferred to the CurvePolygon.

See also

exteriorRing()

setInteriorRings(self, rings: Iterable[QgsCurve])[source]

Sets all interior rings (takes ownership)

Parameters:

rings (Iterable[QgsCurve])

virtual surfaceToPolygon(self) QgsPolygon | None[source]

Gets a polygon representation of this surface. Ownership is transferred to the caller.

Return type:

Optional[QgsPolygon]

virtual toPolygon(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsPolygon | None[source]

Returns a new polygon geometry corresponding to a segmentized approximation of the curve.

Parameters:
  • tolerance (float = M_PI_2/90) – segmentation tolerance

  • toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve

Return type:

Optional[QgsPolygon]

abstract vertexAngle(self, vertex: QgsVertexId) float[source]

Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.

Parameters:

vertex (QgsVertexId) – the vertex id

Return type:

float

Returns:

rotation in radians, clockwise from north