Class: QgsPointXY

class qgis.core.QgsPointXY

Bases: sip.wrapper

QgsPointXY(p: QgsPointXY) Create a point from another point

QgsPointXY(x: float, y: float) Create a point from x,y coordinates

Parameters
  • x – x coordinate

  • y – y coordinate

QgsPointXY(point: Union[QPointF, QPoint]) Create a point from a QPointF

Parameters

point – QPointF source

New in version 2.7.

QgsPointXY(point: QPoint) Create a point from a QPoint

Parameters

point – QPoint source

New in version 2.7.

QgsPointXY(point: QgsPoint) Create a new point. Z and M values will be dropped.

New in version 3.0.

A class to represent a 2D point.

A QgsPointXY represents a position with X and Y coordinates. In most scenarios it is preferable to use a QgsPoint instead which also supports Z and M values.

New in version 3.0: Enums

Methods

asWkt

Returns the well known text representation for the point (e.g.

azimuth

Calculates azimuth between this point and other one (clockwise in degree, starting from north)

compare

Compares this point with another point with a fuzzy tolerance

distance

Returns the distance between this point and a specified x, y coordinate.

isEmpty

Returns True if the geometry is empty.

multiply

Multiply x and y by the given value

project

Returns a new point which corresponds to this point projected by a specified distance in a specified bearing.

set

Sets the x and y value of the point

setX

Sets the x value of the point

setY

Sets the y value of the point

sqrDist

Returns the squared distance between this point a specified x, y coordinate.

sqrDistToSegment

Returns the minimum distance between this point and a segment

toQPointF

Converts a point to a QPointF

toString

Returns a string representation of the point (x, y) with a preset precision.

x

Gets the x value of the point

y

Gets the y value of the point

Signals

Attributes

staticMetaObject

asWkt(self) → str

Returns the well known text representation for the point (e.g. “POINT(x y)”). The wkt is created without an SRID.

azimuth(self, other: QgsPointXY) → float

Calculates azimuth between this point and other one (clockwise in degree, starting from north)

compare(self, other: QgsPointXY, epsilon: float = 4*DBL_EPSILON) → bool

Compares this point with another point with a fuzzy tolerance

Parameters
  • other – point to compare with

  • epsilon – maximum difference for coordinates between the points

Returns

True if points are equal within specified tolerance

New in version 2.9.

distance(self, x: float, y: float) → float

Returns the distance between this point and a specified x, y coordinate.

Parameters
  • x – x-coordniate

  • y – y-coordinate

See also

sqrDist()

New in version 2.16.

distance(self, other: QgsPointXY) -> float Returns the distance between this point and another point.

Parameters

other – other point

See also

sqrDist()

New in version 2.16.

isEmpty(self) → bool

Returns True if the geometry is empty. Unlike QgsPoint, this class is also used to retrieve graphical coordinates like QPointF. It therefore has the default coordinates (0.0). A QgsPointXY is considered empty, when the coordinates have not been explicitly filled in.

New in version 3.10.

multiply(self, scalar: float)

Multiply x and y by the given value

project(self, distance: float, bearing: float) → QgsPointXY

Returns a new point which corresponds to this point projected by a specified distance in a specified bearing.

Parameters
  • distance – distance to project

  • bearing – angle to project in, clockwise in degrees starting from north

New in version 2.16.

set(self, x: float, y: float)

Sets the x and y value of the point

setX(self, x: float)

Sets the x value of the point

Parameters

x – x coordinate

setY(self, y: float)

Sets the y value of the point

Parameters

y – y coordinate

sqrDist(self, x: float, y: float) → float

Returns the squared distance between this point a specified x, y coordinate.

See also

distance()

sqrDist(self, other: QgsPointXY) -> float Returns the squared distance between this point another point.

See also

distance()

sqrDistToSegment(self, x1: float, y1: float, x2: float, y2: float, epsilon: float = DEFAULT_SEGMENT_EPSILON) → Tuple[float, QgsPointXY]

Returns the minimum distance between this point and a segment

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
toQPointF(self) → QPointF

Converts a point to a QPointF

Returns

QPointF with same x and y values

New in version 2.7.

toString(self, precision: int = -1) → str

Returns a string representation of the point (x, y) with a preset precision. If precision is -1, then a default precision will be used.

x(self) → float

Gets the x value of the point

Returns

x coordinate

y(self) → float

Gets the y value of the point

Returns

y coordinate