Class: QgsCurvePolygon

class qgis.core.QgsCurvePolygon

Bases: QgsSurface

Curve polygon geometry type

Methods

addInteriorRing

Adds an interior ring to the geometry (takes ownership)

addMValue

param mValue:

addZValue

param zValue:

adjacentVertices

param vertex:

area

rtype:

float

asGml2

param doc:

asGml3

param doc:

asKml

param precision:

asQPainterPath

rtype:

QPainterPath

asWkb

param flags:

asWkt

param precision:

boundary

rtype:

Optional[QgsAbstractGeometry]

boundingBoxIntersects

param box3d:

calculateBoundingBox

Default calculator for the minimal bounding box for the geometry.

calculateBoundingBox3D

rtype:

QgsBox3D

childCount

rtype:

int

childGeometry

param index:

childPoint

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

clear

clearCache

clone

rtype:

Optional[QgsCurvePolygon]

closestSegment

param pt:

compareToSameClass

param other:

coordinateSequence

rtype:

Any

createEmptyWithSameType

rtype:

Optional[QgsCurvePolygon]

deleteVertex

param position:

dimension

rtype:

int

draw

param p:

dropMValue

rtype:

bool

dropZValue

rtype:

bool

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.

fromWkb

param wkb:

fromWkt

param wkt:

fuzzyDistanceEqual

param other:

fuzzyEqual

param other:

geometryType

rtype:

str

hasChildGeometries

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

hasCurvedSegments

rtype:

bool

insertVertex

param position:

interiorRing

Retrieves an interior ring from the curve polygon.

isEmpty

rtype:

bool

moveVertex

param position:

nCoordinates

rtype:

int

nextVertex

param id:

normalize

numInteriorRings

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

partCount

rtype:

int

perimeter

rtype:

float

removeDuplicateNodes

param epsilon:

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.

ringCount

param part:

roundness

Returns the roundness of the curve polygon.

segmentLength

param startVertex:

segmentize

Returns a geometry without curves.

setExteriorRing

Sets the exterior ring of the polygon.

setInteriorRings

Sets all interior rings (takes ownership)

setZMTypeFromSubGeometry

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

snappedToGrid

param hSpacing:

sortIndex

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

surfaceToPolygon

rtype:

Optional[QgsPolygon]

swapXy

toCurveType

rtype:

Optional[QgsCurvePolygon]

toPolygon

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

transform

param ct:

vertexAngle

Returns approximate rotation angle for a vertex.

vertexAt

param id:

vertexCount

param part:

vertexNumberFromVertexId

param id:

wkbSize

param flags:

addInteriorRing(self, ring: QgsCurve | None)

Adds an interior ring to the geometry (takes ownership)

Parameters:

ring (Optional[QgsCurve])

addMValue(self, mValue: float = 0) bool
Parameters:

mValue (float = 0)

Return type:

bool

addZValue(self, zValue: float = 0) bool
Parameters:

zValue (float = 0)

Return type:

bool

adjacentVertices(self, vertex: QgsVertexId)
Parameters:

vertex (QgsVertexId) -> (QgsVertexId)

area(self) float
Return type:

float

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

asKml(self, precision: int = 17) str
Parameters:

precision (int = 17)

Return type:

str

asQPainterPath(self) QPainterPath
Return type:

QPainterPath

asWkb(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) QByteArray
Parameters:

flags (Union[QgsAbstractGeometry.WkbFlags)

Return type:

QByteArray

asWkt(self, precision: int = 17) str
Parameters:

precision (int = 17)

Return type:

str

boundary(self) QgsAbstractGeometry | None
Return type:

Optional[QgsAbstractGeometry]

boundingBoxIntersects(self, box3d: QgsBox3D) bool
Parameters:

box3d (QgsBox3D)

Return type:

bool

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
Return type:

QgsBox3D

childCount(self) int
Return type:

int

childGeometry(self, index: int) QgsAbstractGeometry | None
Parameters:

index (int)

Return type:

Optional[QgsAbstractGeometry]

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) QgsCurvePolygon | None
Return type:

Optional[QgsCurvePolygon]

closestSegment(self, pt: QgsPoint, epsilon: float = 4 * DBL_EPSILON)
Parameters:
  • pt (QgsPoint)

  • epsilon (float = 4*DBL_EPSILON) -> (float)

compareToSameClass(self, other: QgsAbstractGeometry | None) int
Parameters:

other (Optional[QgsAbstractGeometry])

Return type:

int

coordinateSequence(self) Any
Return type:

Any

createEmptyWithSameType(self) QgsCurvePolygon | None
Return type:

Optional[QgsCurvePolygon]

deleteVertex(self, position: QgsVertexId) bool
Parameters:

position (QgsVertexId)

Return type:

bool

dimension(self) int
Return type:

int

draw(self, p: QPainter)
Parameters:

p (QPainter)

dropMValue(self) bool
Return type:

bool

dropZValue(self) bool
Return type:

bool

exteriorRing(self) QgsCurve | None

Returns the curve polygon’s exterior ring.

See also

interiorRing()

Return type:

Optional[QgsCurve]

forceClockwise(self)

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)

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)

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.

fromWkb(self, wkb: QgsConstWkbPtr) bool
Parameters:

wkb (QgsConstWkbPtr)

Return type:

bool

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

wkt (Optional[str])

Return type:

bool

fuzzyDistanceEqual(self, other: QgsAbstractGeometry, epsilon: float = 1e-08) bool
Parameters:
Return type:

bool

fuzzyEqual(self, other: QgsAbstractGeometry, epsilon: float = 1e-08) bool
Parameters:
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

hasCurvedSegments(self) bool
Return type:

bool

insertVertex(self, position: QgsVertexId, vertex: QgsPoint) bool
Parameters:
Return type:

bool

interiorRing(self, i: int) QgsCurve

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

isEmpty(self) bool
Return type:

bool

moveVertex(self, position: QgsVertexId, newPos: QgsPoint) bool
Parameters:
Return type:

bool

nCoordinates(self) int
Return type:

int

nextVertex(self, id: QgsVertexId)
Parameters:

id (QgsVertexId) -> (bool)

normalize(self)
numInteriorRings(self) int

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

See also

interiorRing()

Return type:

int

partCount(self) int
Return type:

int

perimeter(self) float
Return type:

float

removeDuplicateNodes(self, epsilon: float = 4 * DBL_EPSILON, useZValues: bool = False) bool
Parameters:
  • epsilon (float = 4*DBL_EPSILON)

  • useZValues (bool = False)

Return type:

bool

removeInteriorRing(self, i: int) bool

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)

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)

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

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

ringCount(self, part: int = 0) int
Parameters:

part (int = 0)

Return type:

int

roundness(self) float

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

Added in version 3.24.

Return type:

float

segmentLength(self, startVertex: QgsVertexId) float
Parameters:

startVertex (QgsVertexId)

Return type:

float

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

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]

setExteriorRing(self, ring: QgsCurve | None)

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])

Sets all interior rings (takes ownership)

Parameters:

rings (Iterable[QgsCurve])

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

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

snappedToGrid(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) QgsCurvePolygon | None
Parameters:
  • hSpacing (float)

  • vSpacing (float)

  • dSpacing (float = 0)

  • mSpacing (float = 0)

Return type:

Optional[QgsCurvePolygon]

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.

surfaceToPolygon(self) QgsPolygon | None
Return type:

Optional[QgsPolygon]

swapXy(self)
toCurveType(self) QgsCurvePolygon | None
Return type:

Optional[QgsCurvePolygon]

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

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]

transform(self, ct: QgsCoordinateTransform, d: Qgis.TransformDirection = Qgis.TransformDirection.Forward, transformZ: bool = False)
transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1) None
transform(self, transformer: QgsAbstractGeometryTransformer | None, feedback: QgsFeedback | None = None) bool
Parameters:
  • ct (QgsCoordinateTransform)

  • d (Qgis.TransformDirection = Qgis.TransformDirection.Forward)

  • transformZ (bool = False)

vertexAngle(self, vertex: QgsVertexId) float

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

vertexAt(self, id: QgsVertexId) QgsPoint
Parameters:

id (QgsVertexId)

Return type:

QgsPoint

vertexCount(self, part: int = 0, ring: int = 0) int
Parameters:
  • part (int = 0)

  • ring (int = 0)

Return type:

int

vertexNumberFromVertexId(self, id: QgsVertexId) int
Parameters:

id (QgsVertexId)

Return type:

int

wkbSize(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) int
Parameters:

flags (Union[QgsAbstractGeometry.WkbFlags)

Return type:

int