Class: QgsCoordinateFormatter

class qgis.core.QgsCoordinateFormatter

Bases: sip.wrapper

Contains methods for converting coordinates for display in various formats.

QgsCoordinateFormatter contains static methods for converting numeric coordinates into different formats, for instance as degrees, minutes, seconds values. Note that QgsCoordinateFormatter has no consideration for the validity of converting coordinates to the various display formats, and it is up to the caller to ensure that sensible formats are used for particular coordinates. For instance, ensuring that only geographic coordinates and not projected coordinates are formatted to degree based formats.

New in version 3.0: Enums

Methods

asPair Formats coordinates as an “x,``y``” pair, with optional decimal precision (number of decimal places to include).
format Formats a point according to the specified parameters.
formatX Formats an x coordinate value according to the specified parameters.
formatY Formats a y coordinate value according to the specified parameters.

Signals

Attributes

FlagDegreesPadMinutesSeconds
FlagDegreesUseStringSuffix
FormatDecimalDegrees
FormatDegreesMinutes
FormatDegreesMinutesSeconds
FormatPair
FlagDegreesPadMinutesSeconds = 4
FlagDegreesUseStringSuffix = 2
class Format

Bases: int

FormatDecimalDegrees = 3
FormatDegreesMinutes = 2
FormatDegreesMinutesSeconds = 1
class FormatFlag

Bases: int

class FormatFlags

Bases: sip.wrapper

QgsCoordinateFormatter.FormatFlags(Union[QgsCoordinateFormatter.FormatFlags, QgsCoordinateFormatter.FormatFlag]) QgsCoordinateFormatter.FormatFlags(QgsCoordinateFormatter.FormatFlags)

FormatPair = 0
asPair(x: float, y: float, precision: int = 12) → str

Formats coordinates as an “x,``y``” pair, with optional decimal precision (number of decimal places to include).

format(point: QgsPointXY, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: Union[QgsCoordinateFormatter.FormatFlags, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix) → str

Formats a point according to the specified parameters.

The format argument indicates the desired display format for the coordinate.

The precision argument gives the number of decimal places to include for coordinates.

Optional flags can be specified to control the output format.

formatX(x: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: Union[QgsCoordinateFormatter.FormatFlags, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix) → str

Formats an x coordinate value according to the specified parameters.

The format argument indicates the desired display format for the coordinate.

The precision argument gives the number of decimal places to include for coordinates.

Optional flags can be specified to control the output format.

See also

formatY()

formatY(y: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: Union[QgsCoordinateFormatter.FormatFlags, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix) → str

Formats a y coordinate value according to the specified parameters.

The format argument indicates the desired display format for the coordinate.

The precision argument gives the number of decimal places to include for coordinates.

Optional flags can be specified to control the output format.

See also

formatX()