Subgroup: Curve

Class: QgsCurve

class qgis.core.QgsCurve

Bases: qgis._core.QgsAbstractGeometry

Constructor for QgsCurve.

QgsCurve(QgsCurve)

Abstract base class for curved geometry type

New in version 2.10: Methods

addToPainterPath Adds a curve to a painter path.
adjacentVertices
asQPolygonF Returns a QPolygonF representing the points.
boundary
boundingBox
calculateBoundingBox
childCount
childGeometry
childPoint
clearCache
clone
coordinateSequence
curveToLine Returns a new line string geometry corresponding to a segmentized approximation of the curve.
drawAsPolygon Draws the curve as a polygon on the specified QPainter.
endPoint Returns the end point of the curve.
equals Checks whether this curve exactly equals another curve.
hasChildGeometries
isClosed Returns true if the curve is closed.
isRing Returns true if the curve is a ring.
nextVertex
numPoints Returns the number of points in the curve.
partCount
pointAt Returns the point and vertex id of a point within the curve.
points Returns a list of points within the curve.
reversed Returns a reversed copy of the curve, where the direction of the curve has been flipped.
ringCount
segmentize Returns a geometry without curves.
setZMTypeFromSubGeometry
sinuosity Returns the curve sinuosity, which is the ratio of the curve length() to curve straightDistance2d().
startPoint Returns the starting point of the curve.
straightDistance2d Returns the straight distance of the curve, i.e.
sumUpArea Sums up the area of the curve by iterating over the vertices (shoelace formula).
toCurveType
vertexAt
vertexCount
vertexNumberFromVertexId
xAt Returns the x-coordinate of the specified node in the line string.
yAt Returns the y-coordinate of the specified node in the line string.

Signals

Attributes

addToPainterPath(self, path: QPainterPath)

Adds a curve to a painter path.

adjacentVertices(self, vertex: QgsVertexId) → Tuple[QgsVertexId, QgsVertexId]
asQPolygonF(self) → QPolygonF

Returns a QPolygonF representing the points.

boundary(self) → QgsAbstractGeometry
boundingBox(self) → QgsRectangle
calculateBoundingBox()
childCount(self) → int
childGeometry()
childPoint(self, index: int) → QgsPoint
clearCache(self)
clone(self) → QgsCurve
coordinateSequence(self) → object
curveToLine(self, tolerance: float = M_PI_2/90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) → QgsLineString

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

Parameters:
  • tolerance – segmentation tolerance
  • toleranceType – maximum segmentation angle or maximum difference between approximation and curve

Uses a MaximumAngle tolerance of 1 degrees by default (360 segments in a full circle)

drawAsPolygon(self, p: QPainter)

Draws the curve as a polygon on the specified QPainter.

Parameters:p – destination QPainter
endPoint(self) → QgsPoint

Returns the end point of the curve.

See also

startPoint()

equals(self, other: QgsCurve) → bool

Checks whether this curve exactly equals another curve.

New in version 3.0.

hasChildGeometries()
isClosed(self) → bool

Returns true if the curve is closed.

isRing(self) → bool

Returns true if the curve is a ring.

nextVertex(self, id: QgsVertexId) → Tuple[bool, QgsPoint]
numPoints(self) → int

Returns the number of points in the curve.

partCount(self) → int
pointAt(self, node: int) → Tuple[bool, QgsPoint, QgsVertexId.VertexType]

Returns the point and vertex id of a point within the curve.

Parameters:
  • node – node number, where the first node is 0
  • point – will be set to point at corresponding node in the curve
  • type – will be set to the vertex type of the node
Returns:

true if node exists within the curve

points(self) → object

Returns a list of points within the curve.

reversed(self) → QgsCurve

Returns a reversed copy of the curve, where the direction of the curve has been flipped.

New in version 2.14.

ringCount(self, part: int = 0) → int
segmentize(self, tolerance: float = M_PI_2/90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) → QgsCurve

Returns a geometry without curves. Caller takes ownership

Parameters:
  • tolerance – segmentation tolerance
  • toleranceType – maximum segmentation angle or maximum difference between approximation and curve*
setZMTypeFromSubGeometry()
sinuosity(self) → float

Returns the curve sinuosity, which is the ratio of the curve length() to curve straightDistance2d(). Larger numbers indicate a more “sinuous” curve (i.e. more “bendy”). The minimum value returned of 1.0 indicates a perfectly straight curve.

If a curve isClosed(), it has infinite sinuosity and will return NaN.

New in version 3.2.

startPoint(self) → QgsPoint

Returns the starting point of the curve.

See also

endPoint()

straightDistance2d(self) → float

Returns the straight distance of the curve, i.e. the direct/euclidean distance between the first and last vertex of the curve. (Also known as “as the crow flies” distance).

New in version 3.2.

sumUpArea(self) → float

Sums up the area of the curve by iterating over the vertices (shoelace formula).

toCurveType(self) → QgsCurve
vertexAt(self, id: QgsVertexId) → QgsPoint
vertexCount(self, part: int = 0, ring: int = 0) → int
vertexNumberFromVertexId(self, id: QgsVertexId) → int
xAt(self, index: int) → float

Returns the x-coordinate of the specified node in the line string.

Parameters:index – index of node, where the first node in the line is 0
Returns:x-coordinate of node, or 0.0 if index is out of bounds
yAt(self, index: int) → float

Returns the y-coordinate of the specified node in the line string.

Parameters:index – index of node, where the first node in the line is 0
Returns:y-coordinate of node, or 0.0 if index is out of bounds