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 thatQgsCoordinateFormatter
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:
Methods
Formats coordinates as an "
x
,``y``" pair, with optional decimalprecision
(number of decimal places to include).Formats a
point
according to the specified parameters.Formats an
x
coordinate value according to the specified parameters.Formats a
y
coordinate value according to the specified parameters.Returns the character used as X/Y separator, this is a , on locales that do not use , as decimal separator, it is a space otherwise.
Attributes
- FlagDegreesPadMinutesSeconds = 4¶
- FlagDegreesUseStringSuffix = 2¶
- class Format¶
Bases:
int
- FormatDecimalDegrees = 3¶
- FormatDegreesMinutes = 2¶
- FormatDegreesMinutesSeconds = 1¶
- class FormatFlag¶
Bases:
int
- class FormatFlags¶
- class FormatFlags(Union[QgsCoordinateFormatter.FormatFlags, QgsCoordinateFormatter.FormatFlag])
- class FormatFlags(QgsCoordinateFormatter.FormatFlags)
Bases:
sip.wrapper
- FormatPair = 0¶
- asPair(x: float, y: float, precision: int = 12, order: Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) str ¶
Formats coordinates as an “
x
,``y``” pair, with optional decimalprecision
(number of decimal places to include).Since QGIS 3.26 the optional
order
argument can be used to control the order of the coordinates.- Parameters:
x (float) –
y (float) –
precision (int = 12) –
order (Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) –
- Return type:
str
- format(point: QgsPointXY, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: QgsCoordinateFormatter.FormatFlags | QgsCoordinateFormatter.FormatFlag = QgsCoordinateFormatter.FlagDegreesUseStringSuffix, order: Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) 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.Since QGIS 3.26 the optional
order
argument can be used to control the order of the coordinates.- Parameters:
point (QgsPointXY) –
format (QgsCoordinateFormatter.Format) –
precision (int = 12) –
flags (Union[QgsCoordinateFormatter.FormatFlags) –
order (Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) –
- Return type:
str
- formatX(x: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: 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
- Parameters:
x (float) –
format (QgsCoordinateFormatter.Format) –
precision (int = 12) –
flags (Union[QgsCoordinateFormatter.FormatFlags) –
- Return type:
str
- formatY(y: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: 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
- Parameters:
y (float) –
format (QgsCoordinateFormatter.Format) –
precision (int = 12) –
flags (Union[QgsCoordinateFormatter.FormatFlags) –
- Return type:
str
- separator() str ¶
Returns the character used as X/Y separator, this is a , on locales that do not use , as decimal separator, it is a space otherwise.
New in version 3.20.
- Return type:
str