Class: QgsOgcUtils

class qgis.core.QgsOgcUtils

Bases: sip.wrapper

The QgsOgcUtils class provides various utility functions for conversion between OGC (Open Geospatial Consortium) standards and QGIS internal representations.

Currently supported standards:

  • GML2 - Geography Markup Language (import, export)

Methods

colorFromOgcFill

Parse XML with OGC fill into QColor

expressionFromOgcFilter

Parse XML with OGC filter into QGIS expression

expressionToOgcExpression

Creates an OGC expression XML element from the exp expression with default values for the geometry name, srs name, honourAsisOrientation and invertAxisOrientation.

expressionToOgcFilter

Creates OGC filter XML element.

geometryFromGML

Static method that creates geometry from GML

geometryToGML

Exports the geometry to GML

rectangleFromGMLBox

Read rectangle from GML2 Box

rectangleFromGMLEnvelope

Read rectangle from GML3 Envelope

rectangleToGMLBox

Exports the rectangle to GML2 Box

rectangleToGMLEnvelope

Exports the rectangle to GML3 Envelope

Attributes

FILTER_FES_2_0

FILTER_OGC_1_0

FILTER_OGC_1_1

GML_2_1_2

GML_3_1_0

GML_3_2_1

class Context(layer: QgsMapLayer = None, transformContext: QgsCoordinateTransformContext = QgsCoordinateTransformContext())

Bases: sip.wrapper

Constructs a Context from layer and transformContext

QgsOgcUtils.Context(QgsOgcUtils.Context)

layer
transformContext
FILTER_FES_2_0 = 2
FILTER_OGC_1_0 = 0
FILTER_OGC_1_1 = 1
class FilterVersion

Bases: int

class GMLVersion

Bases: int

GML_2_1_2 = 0
GML_3_1_0 = 1
GML_3_2_1 = 2
colorFromOgcFill(fillElement: QDomElement) QColor

Parse XML with OGC fill into QColor

Parameters

fillElement (QDomElement) –

Return type

QColor

expressionFromOgcFilter(element: QDomElement, layer: QgsVectorLayer = None) QgsExpression

Parse XML with OGC filter into QGIS expression

expressionFromOgcFilter(element: QDomElement, version: QgsOgcUtils.FilterVersion, layer: QgsVectorLayer = None) -> QgsExpression Returns an expression from a WFS filter embedded in a document.

Parameters
  • element (QDomElement) – The WFS Filter

  • version – The WFS version

  • layer (QgsVectorLayer = None) – Layer to use to retrieve field values from literal filters

New in version 3.4.

Return type

QgsExpression

expressionToOgcExpression(exp: QgsExpression, doc: QDomDocument, errorMessage: str = '', requiresFilterElement: bool = False) QDomElement

Creates an OGC expression XML element from the exp expression with default values for the geometry name, srs name, honourAsisOrientation and invertAxisOrientation.

Returns

valid OGC expression QDomElement on success or a valid verbatim <Filter> endverbatim QDomElement when requiresFilterElement is set. otherwise null QDomElement

expressionToOgcExpression(exp: QgsExpression, doc: QDomDocument, gmlVersion: QgsOgcUtils.GMLVersion, filterVersion: QgsOgcUtils.FilterVersion, geometryName: str, srsName: str, honourAxisOrientation: bool, invertAxisOrientation: bool, errorMessage: str = ‘’, requiresFilterElement: bool = False) -> QDomElement Creates an OGC expression XML element from the exp expression.

Return type

QDomElement

Returns

valid OGC expression QDomElement on success or a valid verbatim <Filter> endverbatim QDomElement when requiresFilterElement is set. otherwise null QDomElement

Parameters
  • exp (QgsExpression) –

  • doc (QDomDocument) –

  • errorMessage (str = '') –

  • requiresFilterElement (bool = False) –

expressionToOgcFilter(exp: QgsExpression, doc: QDomDocument, errorMessage: str = '') QDomElement

Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)

Return type

QDomElement

Returns

valid verbatim <Filter> endverbatim QDomElement on success, otherwise null QDomElement

Parameters
  • exp (QgsExpression) –

  • doc (QDomDocument) –

  • errorMessage (str = '') –

geometryFromGML(xmlString: str, context: QgsOgcUtils.Context = QgsOgcUtils.Context()) QgsGeometry

Static method that creates geometry from GML

Parameters
  • xmlString (str) – xml representation of the geometry. GML elements are expected to be in default namespace (verbatim {<Point>…</Point> endverbatim) or in “gml” namespace (verbatim <gml:Point>…</gml:Point> endverbatim)

  • context (QgsOgcUtils.Context = QgsOgcUtils.Context()) – QgsOgcUtils context

geometryFromGML(geometryNode: QDomNode, context: QgsOgcUtils.Context = QgsOgcUtils.Context()) -> QgsGeometry Static method that creates geometry from GML

Return type

QgsGeometry

geometryToGML(geometry: QgsGeometry, doc: QDomDocument, gmlVersion: QgsOgcUtils.GMLVersion, srsName: str, invertAxisOrientation: bool, gmlIdBase: str, precision: int = 17) QDomElement

Exports the geometry to GML

Returns

QDomElement

New in version 2.16.

geometryToGML(geometry: QgsGeometry, doc: QDomDocument, format: str, precision: int = 17) -> QDomElement Exports the geometry to GML2 or GML3

Returns

QDomElement

geometryToGML(geometry: QgsGeometry, doc: QDomDocument, precision: int = 17) -> QDomElement Exports the geometry to GML2

Return type

QDomElement

Returns

QDomElement

Parameters
  • geometry (QgsGeometry) –

  • doc (QDomDocument) –

  • gmlVersion (QgsOgcUtils.GMLVersion) –

  • srsName (str) –

  • invertAxisOrientation (bool) –

  • gmlIdBase (str) –

  • precision (int = 17) –

rectangleFromGMLBox(boxNode: QDomNode) QgsRectangle

Read rectangle from GML2 Box

Parameters

boxNode (QDomNode) –

Return type

QgsRectangle

rectangleFromGMLEnvelope(envelopeNode: QDomNode) QgsRectangle

Read rectangle from GML3 Envelope

Parameters

envelopeNode (QDomNode) –

Return type

QgsRectangle

rectangleToGMLBox(box: QgsRectangle, doc: QDomDocument, precision: int = 17) QDomElement

Exports the rectangle to GML2 Box

Returns

QDomElement

rectangleToGMLBox(box: QgsRectangle, doc: QDomDocument, srsName: str, invertAxisOrientation: bool, precision: int = 17) -> QDomElement Exports the rectangle to GML2 Box

Return type

QDomElement

Returns

QDomElement

New in version 2.16.

Parameters
  • box (QgsRectangle) –

  • doc (QDomDocument) –

  • precision (int = 17) –

rectangleToGMLEnvelope(env: QgsRectangle, doc: QDomDocument, precision: int = 17) QDomElement

Exports the rectangle to GML3 Envelope

Returns

QDomElement

rectangleToGMLEnvelope(env: QgsRectangle, doc: QDomDocument, srsName: str, invertAxisOrientation: bool, precision: int = 17) -> QDomElement Exports the rectangle to GML3 Envelope

Return type

QDomElement

Returns

QDomElement

New in version 2.16.

Parameters
  • env (QgsRectangle) –

  • doc (QDomDocument) –

  • precision (int = 17) –