Subgroup: Curve

Class: QgsCurve

class qgis.core.QgsCurve

Bases: qgis._core.QgsAbstractGeometry

Abstract base class for curved geometry type

New in version 2.10: Methods

addMValue Adds a measure to the geometry, initialized to a preset value.
addToPainterPath Adds a curve to a painter path.
addZValue Adds a z-dimension to the geometry, initialized to a preset value.
adjacentVertices
area Returns the area of the geometry.
asGml2 Returns a GML2 representation of the geometry.
asGml3 Returns a GML3 representation of the geometry.
asJson Returns a GeoJSON representation of the geometry.
asQPolygonF Returns a QPolygonF representing the points.
asWkb Returns a WKB representation of the geometry.
asWkt Returns a WKT representation of the geometry.
boundary
boundingBox
calculateBoundingBox
centroid Returns the centroid of the geometry
childCount
childGeometry
childPoint
clear Clears the geometry, ie reset it to a null geometry
clearCache
clone
closestSegment Searches for the closest segment of the geometry to a given point.
convertTo Converts the geometry to a specified type.
coordinateSequence
createEmptyWithSameType
curveToLine Returns a new line string geometry corresponding to a segmentized approximation of the curve.
deleteVertex Deletes a vertex within the geometry
dimension Returns the inherent dimension of the geometry.
draw Draws the geometry using the specified QPainter.
drawAsPolygon Draws the curve as a polygon on the specified QPainter.
dropMValue Drops any measure values which exist in the geometry.
dropZValue Drops any z-dimensions which exist in the geometry.
endPoint Returns the end point of the curve.
equals Checks whether this curve exactly equals another curve.
fromWkb Sets the geometry from a WKB string.
fromWkt Sets the geometry from a WKT string.
geometryType Returns a unique string representing the geometry type.
hasChildGeometries
hasCurvedSegments Returns true if the geometry contains curved segments
insertVertex Inserts a vertex into the geometry
is3D Returns true if the geometry is 3D and contains a z-value.
isClosed Returns true if the curve is closed.
isEmpty Returns true if the geometry is empty
isMeasure Returns true if the geometry contains m values.
isRing Returns true if the curve is a ring.
length Returns the length of the geometry.
moveVertex Moves a vertex within the geometry
nCoordinates Returns the number of nodes contained in the geometry
nextVertex
numPoints Returns the number of points in the curve.
partCount
perimeter Returns the perimeter of the geometry.
pointAt Returns the point and vertex id of a point within the curve.
points Returns a list of points within the curve.
removeDuplicateNodes Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerate geometry.
reversed Returns a reversed copy of the curve, where the direction of the curve has been flipped.
ringCount
segmentLength Returns the length of the segment of the geometry which begins at startVertex.
segmentize Returns a geometry without curves.
setZMTypeFromSubGeometry
snappedToGrid Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
startPoint Returns the starting point of the curve.
sumUpArea Sums up the area of the curve by iterating over the vertices (shoelace formula).
toCurveType
transform Transforms the geometry using a coordinate transform
vertexAngle Returns approximate angle at a vertex.
vertexAt
vertexCount
vertexNumberFromVertexId
vertices Returns Java-style iterator for traversal of vertices of the geometry
wkbType Returns the WKB type of the geometry.
wktTypeStr Returns the WKT type string of the geometry.
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.

Attributes

MaximumAngle
MaximumDifference
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
createEmptyWithSameType()
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()
startPoint(self) → QgsPoint

Returns the starting point of the curve.

See also

endPoint()

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

See also

setXAt()

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

See also

setYAt()