Class: QgsCoordinateFormatter¶
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.
Static Methods
Formats coordinates as an "x,`y`" pair, with optional decimal precision (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
- class qgis.core.QgsCoordinateFormatter[source]¶
Bases:
object
- FlagDegreesPadMinutesSeconds = 4¶
- FlagDegreesUseStringSuffix = 2¶
- class Format¶
Bases:
int
- FormatDecimalDegrees = 3¶
- FormatDegreesMinutes = 2¶
- FormatDegreesMinutesSeconds = 1¶
- class FormatFlag¶
Bases:
int
- class FormatFlags¶
- class FormatFlags(f: QgsCoordinateFormatter.FormatFlags | QgsCoordinateFormatter.FormatFlag)
- class FormatFlags(a0: QgsCoordinateFormatter.FormatFlags)
Bases:
object
- FormatPair = 0¶
- static asPair(x: float, y: float, precision: int = 12, order: Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) str [source]¶
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
- static format(point: QgsPointXY, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: QgsCoordinateFormatter.FormatFlags | QgsCoordinateFormatter.FormatFlag = QgsCoordinateFormatter.FlagDegreesUseStringSuffix, order: Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY) str [source]¶
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, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix)
order (Qgis.CoordinateOrder = Qgis.CoordinateOrder.XY)
- Return type:
str
- static formatX(x: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: QgsCoordinateFormatter.FormatFlags | QgsCoordinateFormatter.FormatFlag = QgsCoordinateFormatter.FlagDegreesUseStringSuffix) str [source]¶
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, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix)
- Return type:
str
- static formatY(y: float, format: QgsCoordinateFormatter.Format, precision: int = 12, flags: QgsCoordinateFormatter.FormatFlags | QgsCoordinateFormatter.FormatFlag = QgsCoordinateFormatter.FlagDegreesUseStringSuffix) str [source]¶
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, QgsCoordinateFormatter.FormatFlag] = QgsCoordinateFormatter.FlagDegreesUseStringSuffix)
- Return type:
str