Subgroup: Line
Class: QgsLineString¶
-
class
qgis.core.
QgsLineString
¶ Bases:
qgis._core.QgsCurve
Line string geometry type, with support for z-dimension and m-values.
New in version 2.10: Methods
addMValue
addToPainterPath
addVertex
Adds a new vertex to the end of the line string. addZValue
adjacentVertices
append
Appends the contents of another line string to the end of this line string. area
Returns the area of the geometry. asGml2
asGml3
asJson
asQPolygonF
Returns a QPolygonF representing the points. asWkb
asWkt
boundary
boundingBox
calculateBoundingBox
centroid
childCount
childGeometry
childPoint
clear
clearCache
clone
close
Closes the line string by appending the first point to the end of the line, if it is not already closed. closestSegment
convertTo
coordinateSequence
createEmptyWithSameType
curveToLine
Returns a new line string geometry corresponding to a segmentized approximation of the curve. deleteVertex
dimension
draw
drawAsPolygon
dropMValue
dropZValue
endPoint
equals
extend
Extends the line geometry by extrapolating out the start or end of the line by a specified distance. fromWkb
fromWkt
geometryType
hasChildGeometries
hasCurvedSegments
Returns true if the geometry contains curved segments insertVertex
is3D
Returns true if the geometry is 3D and contains a z-value. isClosed
Returns true if the curve is closed. isEmpty
isMeasure
Returns true if the geometry contains m values. isRing
Returns true if the curve is a ring. length
mAt
Returns the m value of the specified node in the line string. moveVertex
nCoordinates
nextVertex
numPoints
partCount
perimeter
Returns the perimeter of the geometry. pointAt
pointN
Returns the specified point from inside the line string. points
removeDuplicateNodes
reversed
ringCount
segmentLength
segmentize
Returns a geometry without curves. setMAt
Sets the m value of the specified node in the line string. setPoints
Resets the line string to match the specified list of points. setXAt
Sets the x-coordinate of the specified node in the line string. setYAt
Sets the y-coordinate of the specified node in the line string. setZAt
Sets the z-coordinate of the specified node in the line string. setZMTypeFromSubGeometry
snappedToGrid
startPoint
sumUpArea
toCurveType
Returns the geometry converted to the more generic curve type QgsCompoundCurve
transform
transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1) vertexAngle
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
yAt
zAt
Returns the z-coordinate of the specified node in the line string. Attributes
MaximumAngle
MaximumDifference
-
addMValue
(self, mValue: float = 0) → bool¶
-
addToPainterPath
(self, path: QPainterPath)¶
-
addVertex
(self, pt: QgsPoint)¶ Adds a new vertex to the end of the line string.
Parameters: pt – vertex to add
-
addZValue
(self, zValue: float = 0) → bool¶
-
append
(self, line: QgsLineString)¶ Appends the contents of another line string to the end of this line string.
Parameters: line – line to append. Ownership is not transferred.
-
asGml2
(self, doc: QDomDocument, precision: int = 17, ns: str = '') → QDomElement¶
-
asGml3
(self, doc: QDomDocument, precision: int = 17, ns: str = '') → QDomElement¶
-
asJson
(self, precision: int = 17) → str¶
-
asWkb
(self) → QByteArray¶
-
asWkt
(self, precision: int = 17) → str¶
-
calculateBoundingBox
(self) → QgsRectangle¶
-
centroid
(self) → QgsPoint¶
-
childCount
()¶
-
childGeometry
()¶
-
childPoint
()¶
-
clear
(self)¶
-
clearCache
()¶
-
clone
(self) → QgsLineString¶
-
close
(self)¶ Closes the line string by appending the first point to the end of the line, if it is not already closed.
-
closestSegment
(self, pt: QgsPoint, epsilon: float = 4*DBL_EPSILON) → Tuple[float, QgsPoint, QgsVertexId, int]¶
-
convertTo
(self, type: QgsWkbTypes.Type) → bool¶
-
createEmptyWithSameType
(self) → QgsLineString¶
-
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*
-
deleteVertex
(self, position: QgsVertexId) → bool¶
-
dimension
(self) → int¶
-
draw
(self, p: QPainter)¶
-
drawAsPolygon
(self, p: QPainter)¶
-
dropMValue
(self) → bool¶
-
dropZValue
(self) → bool¶
-
endPoint
(self) → QgsPoint¶
-
equals
(self, other: QgsCurve) → bool¶
-
extend
(self, startDistance: float, endDistance: float)¶ Extends the line geometry by extrapolating out the start or end of the line by a specified distance. Lines are extended using the bearing of the first or last segment in the line.
New in version 3.0.
-
fromWkb
(self, wkb: QgsConstWkbPtr) → bool¶
-
fromWkt
(self, wkt: str) → bool¶
-
geometryType
(self) → str¶
-
hasChildGeometries
()¶
-
insertVertex
(self, position: QgsVertexId, vertex: QgsPoint) → bool¶
-
isEmpty
(self) → bool¶
-
length
(self) → float¶
-
mAt
(self, index: int) → float¶ Returns the m value of the specified node in the line string.
Parameters: index – index of node, where the first node in the line is 0 Returns: m value of node, or nan
if index is out of bounds or the linedoes not have m values
See also
-
moveVertex
(self, position: QgsVertexId, newPos: QgsPoint) → bool¶
-
nCoordinates
(self) → int¶
-
numPoints
(self) → int¶
-
pointAt
(self, node: int, point: QgsPoint) → Tuple[bool, QgsVertexId.VertexType]¶
-
pointN
(self, i: int) → QgsPoint¶ Returns the specified point from inside the line string.
Parameters: i – index of point, starting at 0 for the first point
-
points
(self) → object¶
-
removeDuplicateNodes
(self, epsilon: float = 4*DBL_EPSILON, useZValues: bool = False) → bool¶
-
reversed
(self) → QgsLineString¶
-
segmentLength
(self, startVertex: QgsVertexId) → float¶
-
setMAt
(self, index: int, m: float)¶ Sets the m value of the specified node in the line string.
Parameters: index – index of node, where the first node in the line is 0. Corresponding node must already exist in line string, and the line string must have m values. :param m: m value of node
See also
-
setPoints
(self, points: object)¶ Resets the line string to match the specified list of points. The line string will inherit the dimensionality of the first point in the list.
Parameters: points – new points for line string. If empty, line string will be cleared.
-
setXAt
(self, index: int, x: float)¶ Sets 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. Corresponding node must already exist in line string. :param x: x-coordinate of node
See also
-
setYAt
(self, index: int, y: float)¶ Sets 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. Corresponding node must already exist in line string. :param y: y-coordinate of node
See also
-
setZAt
(self, index: int, z: float)¶ Sets the z-coordinate of the specified node in the line string.
Parameters: index – index of node, where the first node in the line is 0. Corresponding node must already exist in line string, and the line string must have z-dimension. :param z: z-coordinate of node
See also
-
setZMTypeFromSubGeometry
()¶
-
snappedToGrid
(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) → QgsLineString¶
-
startPoint
(self) → QgsPoint¶
-
sumUpArea
(self) → float¶
-
toCurveType
(self) → QgsCompoundCurve¶ Returns the geometry converted to the more generic curve type
QgsCompoundCurve
Returns: the converted geometry. Caller takes ownership*
-
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)
-
vertexAngle
(self, vertex: QgsVertexId) → float¶
-
xAt
(self, index: int) → float¶
-
yAt
(self, index: int) → float¶
-