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.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.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]) → None
- class FormatFlags(QgsCoordinateFormatter.FormatFlags) → None
Bases:
sip.wrapper
- FormatPair = 0¶
- asPair(x: float, y: float, precision: int = 12) → str¶
Formats coordinates as an “
x
,``y``” pair, with optional decimalprecision
(number of decimal places to include).- Parameters
x (float) –
y (float) –
precision (int = 12) –
- Return type
str
- 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.- Parameters
point (QgsPointXY) –
format (QgsCoordinateFormatter.Format) –
precision (int = 12) –
flags (Union[QgsCoordinateFormatter.FormatFlags) –
- Return type
str
- 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
- 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: 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
- Parameters
y (float) –
format (QgsCoordinateFormatter.Format) –
precision (int = 12) –
flags (Union[QgsCoordinateFormatter.FormatFlags) –
- Return type
str