Subgroup: Point
Class: QgsPoint¶
-
class
qgis.core.
QgsPoint
(x: float = 0, y: float = 0, z: object = Py_None, m: object = Py_None, wkbType: QgsWkbTypes.Type = QgsWkbTypes.Unknown)¶ Bases:
qgis._core.QgsAbstractGeometry
Construct a point with the provided initial coordinate values.
If
wkbType
is set to QgsWkbTypes.Point, QgsWkbTypes.PointZ, QgsWkbTypes.PointM or QgsWkbTypes.PointZM the type will be set accordingly. If it is left to the default QgsWkbTypes.Unknown, the type will be set based on the following rules: - If only x and y are specified, the type will be a 2D point. - If any or both of the Z and M are specified, the appropriate type will be created.pt = QgsPoint(43.4, 5.3) pt.asWkt() # Point(43.4 5.3) pt_z = QgsPoint(120, 343, 77) pt.asWkt() # PointZ(120 343 77) pt_m = QgsPoint(33, 88, m=5) pt_m.m() # 5 pt_m.wkbType() # QgsWkbTypes.PointM pt = QgsPoint(30, 40, wkbType=QgsWkbTypes.PointZ) pt.z() # nan pt.wkbType() # QgsWkbTypes.PointZ
QgsPoint(p: QgsPointXY) Construct a QgsPoint from a QgsPointXY object
QgsPoint(p: Union[QPointF, QPoint]) Construct a QgsPoint from a QPointF
QgsPoint(QgsPoint)
Point geometry type, with support for z-dimension and m-values.New in version 3.0: Methods
addMValue
addZValue
adjacentVertices
asGml2
asGml3
asJson
asWkb
asWkt
azimuth
Calculates azimuth between this point and other one (clockwise in degree, starting from north) boundary
boundingBox
calculateBoundingBox
childCount
childGeometry
childPoint
clear
clearCache
clone
closestSegment
convertTo
coordinateSequence
createEmptyWithSameType
deleteVertex
dimension
distance
Returns the distance between this point and a specified x, y coordinate. distance3D
Returns the 3D distance between this point and a specified x, y, z coordinate. distanceSquared
Returns the squared distance between this point a specified x, y coordinate. distanceSquared3D
Returns the 3D squared distance between this point a specified x, y, z coordinate. draw
dropMValue
dropZValue
fromWkb
fromWkt
geometryType
hasChildGeometries
inclination
Calculates inclination between this point and other one (starting from zenith = 0 to nadir = 180. insertVertex
isEmpty
m
Returns the point’s m value. moveVertex
nCoordinates
nextVertex
partCount
project
Returns a new point which correspond to this point projected by a specified distance with specified angles (azimuth and inclination). removeDuplicateNodes
ringCount
segmentLength
setM
Sets the point’s m-value. setX
Sets the point’s x-coordinate. setY
Sets the point’s y-coordinate. setZ
Sets the point’s z-coordinate. setZMTypeFromSubGeometry
snappedToGrid
toCurveType
toQPointF
Returns the point as a QPointF. transform
transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1) vertexAngle
Angle undefined. vertexAt
vertexCount
vertexNumberFromVertexId
x
Returns the point’s x-coordinate. y
Returns the point’s y-coordinate. z
Returns the point’s z-coordinate. Signals
Attributes
-
addMValue
(self, mValue: float = 0) → bool¶
-
addZValue
(self, zValue: float = 0) → bool¶
-
adjacentVertices
(self, vertex: QgsVertexId) → Tuple[QgsVertexId, QgsVertexId]¶
-
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¶
-
azimuth
(self, other: QgsPoint) → float¶ Calculates azimuth between this point and other one (clockwise in degree, starting from north)
New in version 3.0.
-
boundary
(self) → QgsAbstractGeometry¶
-
boundingBox
(self) → QgsRectangle¶
-
calculateBoundingBox
()¶
-
childCount
(self) → int¶
-
childGeometry
()¶
-
childPoint
(self, index: int) → QgsPoint¶
-
clear
(self)¶
-
clearCache
()¶
-
clone
(self) → QgsPoint¶
-
closestSegment
(self, pt: QgsPoint, epsilon: float = 4*DBL_EPSILON) → Tuple[float, QgsPoint, QgsVertexId, int]¶
-
convertTo
(self, type: QgsWkbTypes.Type) → bool¶
-
coordinateSequence
(self) → object¶
-
createEmptyWithSameType
(self) → QgsPoint¶
-
deleteVertex
(self, position: QgsVertexId) → bool¶
-
dimension
(self) → int¶
-
distance
(self, x: float, y: float) → float¶ Returns the distance between this point and a specified x, y coordinate. In certain cases it may be more appropriate to call the faster distanceSquared() method, e.g., when comparing distances.
New in version 3.0.
See also
distance(self, other: QgsPoint) -> float Returns the 2D distance between this point and another point. In certain cases it may be more appropriate to call the faster distanceSquared() method, e.g., when comparing distances.
New in version 3.0.
-
distance3D
(self, x: float, y: float, z: float) → float¶ Returns the 3D distance between this point and a specified x, y, z coordinate. In certain cases it may be more appropriate to call the faster distanceSquared() method, e.g., when comparing distances.
New in version 3.0.
See also
distance3D(self, other: QgsPoint) -> float Returns the 3D distance between this point and another point. In certain cases it may be more appropriate to call the faster distanceSquared() method, e.g., when comparing distances.
New in version 3.0.
-
distanceSquared
(self, x: float, y: float) → float¶ Returns the squared distance between this point a specified x, y coordinate. Calling this is faster than calling distance(), and may be useful in use cases such as comparing distances where the extra expense of calling distance() is not required.
See also
New in version 3.0.
distanceSquared(self, other: QgsPoint) -> float Returns the squared distance between this point another point. Calling this is faster than calling distance(), and may be useful in use cases such as comparing distances where the extra expense of calling distance() is not required.
See also
New in version 3.0.
-
distanceSquared3D
(self, x: float, y: float, z: float) → float¶ Returns the 3D squared distance between this point a specified x, y, z coordinate. Calling this is faster than calling distance(), and may be useful in use cases such as comparing distances where the extra expense of calling distance() is not required.
See also
New in version 3.0.
distanceSquared3D(self, other: QgsPoint) -> float Returns the 3D squared distance between this point another point. Calling this is faster than calling distance(), and may be useful in use cases such as comparing distances where the extra expense of calling distance() is not required.
See also
New in version 3.0.
-
draw
(self, p: QPainter)¶
-
dropMValue
(self) → bool¶
-
dropZValue
(self) → bool¶
-
fromWkb
(self, wkb: QgsConstWkbPtr) → bool¶
-
fromWkt
(self, wkt: str) → bool¶
-
geometryType
(self) → str¶
-
hasChildGeometries
()¶
-
inclination
(self, other: QgsPoint) → float¶ Calculates inclination between this point and other one (starting from zenith = 0 to nadir = 180. Horizon = 90) Returns 90.0 if the distance between this point and other one is equal to 0 (same point).
New in version 3.0.
-
insertVertex
(self, position: QgsVertexId, vertex: QgsPoint) → bool¶
-
isEmpty
(self) → bool¶
-
moveVertex
(self, position: QgsVertexId, newPos: QgsPoint) → bool¶
-
nCoordinates
(self) → int¶
-
nextVertex
(self, id: QgsVertexId) → Tuple[bool, QgsPoint]¶
-
partCount
(self) → int¶
-
project
(self, distance: float, azimuth: float, inclination: float = 90) → QgsPoint¶ Returns a new point which correspond to this point projected by a specified distance with specified angles (azimuth and inclination). M value is preserved.
Parameters: - distance – distance to project
- azimuth – angle to project in X Y, clockwise in degrees starting from north
- inclination – angle to project in Z (3D). If the point is 2D, the Z value is assumed to be 0.
Returns: The point projected. If a 2D point is projected a 3D point will be returned except if
inclination is 90. A 3D point is always returned if a 3D point is projected. Example: .. code-block:: python
p = QgsPoint( 1, 2 ) # 2D point pr = p.project ( 1, 0 ) # pr is a 2D point: ‘Point (1 3)’ pr = p.project ( 1, 0, 90 ) # pr is a 2D point: ‘Point (1 3)’ pr = p.project (1, 0, 0 ) # pr is a 3D point: ‘PointZ (1 2 1)’ p = QgsPoint( QgsWkbTypes.PointZ, 1, 2, 2 ) # 3D point pr = p.project ( 1, 0 ) # pr is a 3D point: ‘PointZ (1 3 2)’ pr = p.project ( 1, 0, 90 ) # pr is a 3D point: ‘PointZ (1 3 2)’ pr = p.project (1, 0, 0 ) # pr is a 3D point: ‘PointZ (1 2 3)’New in version 3.0.
-
removeDuplicateNodes
(self, epsilon: float = 4*DBL_EPSILON, useZValues: bool = False) → bool¶
-
ringCount
(self, int = 0) → int¶
-
segmentLength
(self, startVertex: QgsVertexId) → float¶
-
setM
(self, m: float)¶ Sets the point’s m-value.
Note
calling this will have no effect if the point does not contain a m-dimension. Use addMValue() to add a m value and force the point to have an m dimension.
See also
m
See also
rm()
-
setX
(self, x: float)¶ Sets the point’s x-coordinate.
See also
x
See also
rx()
-
setY
(self, y: float)¶ Sets the point’s y-coordinate.
See also
y
See also
ry()
-
setZ
(self, z: float)¶ Sets the point’s z-coordinate.
Note
calling this will have no effect if the point does not contain a z-dimension. Use addZValue() to add a z value and force the point to have a z dimension.
See also
z
See also
rz()
-
setZMTypeFromSubGeometry
()¶
-
snappedToGrid
(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) → QgsPoint¶
-
toCurveType
(self) → QgsPoint¶
-
toQPointF
(self) → QPointF¶ Returns the point as a QPointF.
New in version 2.14.
-
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¶ Angle undefined. Always returns 0.0
Parameters: vertex – the vertex id Returns: 0.0*
-
vertexAt
(self, QgsVertexId) → QgsPoint¶
-
vertexCount
(self, int = 0, int = 0) → int¶
-
vertexNumberFromVertexId
(self, id: QgsVertexId) → int¶
-