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

asWkb

rtype

QByteArray

asWkt

param precision

boundary

rtype

QgsAbstractGeometry

calculateBoundingBox

rtype

QgsRectangle

childCount

rtype

int

childGeometry

param index

childPoint

clear

clearCache

clone

rtype

QgsCurvePolygon

closestSegment

param pt

coordinateSequence

rtype

object

createEmptyWithSameType

rtype

QgsCurvePolygon

deleteVertex

param position

dimension

rtype

int

draw

param p

dropMValue

rtype

bool

dropZValue

rtype

bool

exteriorRing

Returns the curve polygon’s exterior ring.

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

geometryType

rtype

str

hasChildGeometries

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

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

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

snappedToGrid

param hSpacing

surfaceToPolygon

rtype

QgsPolygon

swapXy

toCurveType

rtype

QgsCurvePolygon

toPolygon

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

transform

transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1)

vertexAngle

Returns approximate rotation angle for a vertex.

vertexAt

param id

vertexCount

param part

vertexNumberFromVertexId

param id

addInteriorRing(self, ring: QgsCurve)

Adds an interior ring to the geometry (takes ownership)

Parameters

ring (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) → Tuple[QgsVertexId, QgsVertexId]
Parameters

vertex (QgsVertexId) –

Return type

Tuple[QgsVertexId, QgsVertexId]

area(self) → float
Return type

float

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

  • precision (int = 17) –

  • ns (str = '') –

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

Return type

QDomElement

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

  • precision (int = 17) –

  • ns (str = '') –

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

Return type

QDomElement

asWkb(self) → QByteArray
Return type

QByteArray

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

precision (int = 17) –

Return type

str

boundary(self) → QgsAbstractGeometry
Return type

QgsAbstractGeometry

calculateBoundingBox(self) → QgsRectangle
Return type

QgsRectangle

childCount(self) → int
Return type

int

childGeometry(self, index: int) → QgsAbstractGeometry
Parameters

index (int) –

Return type

QgsAbstractGeometry

childPoint()
clear(self)
clearCache()
clone(self) → QgsCurvePolygon
Return type

QgsCurvePolygon

closestSegment(self, pt: QgsPoint, epsilon: float = 4*DBL_EPSILON) → Tuple[float, QgsPoint, QgsVertexId, int]
Parameters
  • pt (QgsPoint) –

  • epsilon (float = 4*DBL_EPSILON) –

Return type

Tuple[float, QgsPoint, QgsVertexId, int]

coordinateSequence(self) → object
Return type

object

createEmptyWithSameType(self) → QgsCurvePolygon
Return type

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

Returns the curve polygon’s exterior ring.

See also

interiorRing()

Return type

QgsCurve

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.

New in version 3.6.

fromWkb(self, wkb: QgsConstWkbPtr) → bool
Parameters

wkb (QgsConstWkbPtr) –

Return type

bool

fromWkt(self, wkt: str) → bool
Parameters

wkt (str) –

Return type

bool

geometryType(self) → str
Return type

str

hasChildGeometries()
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.

An IndexError will be raised 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) → Tuple[bool, QgsPoint]
Parameters

id (QgsVertexId) –

Return type

Tuple[bool, QgsPoint]

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.

An IndexError will be raised 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.

New in version 3.0.

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.

New in version 3.0.

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

part (int = 0) –

Return type

int

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

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

QgsAbstractGeometry

setExteriorRing(self, ring: QgsCurve)

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 (QgsCurve) – new exterior ring. Ownership is transferred to the CurvePolygon.

See also

exteriorRing()

setInteriorRings(self, rings: object)

Sets all interior rings (takes ownership)

Parameters

rings (object) –

setZMTypeFromSubGeometry()
snappedToGrid(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) → QgsCurvePolygon
Parameters
  • hSpacing (float) –

  • vSpacing (float) –

  • dSpacing (float = 0) –

  • mSpacing (float = 0) –

Return type

QgsCurvePolygon

surfaceToPolygon(self) → QgsPolygon
Return type

QgsPolygon

swapXy(self)
toCurveType(self) → QgsCurvePolygon
Return type

QgsCurvePolygon

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

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

QgsPolygon

transform(self, ct: QgsCoordinateTransform, d: QgsCoordinateTransform.TransformDirection = QgsCoordinateTransform.ForwardTransform, transformZ: bool = False)

transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1)

Parameters
  • ct (QgsCoordinateTransform) –

  • d (QgsCoordinateTransform.TransformDirection = QgsCoordinateTransform.ForwardTransform) –

  • 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