Class: QgsWkbTypes

class qgis.core.QgsWkbTypes

Bases: sip.wrapper

Handles storage of information regarding WKB types and their properties.

Enums

GeometryType

Bases: enum.IntEnum

Type

alias of WkbType

Methods

addM

Adds the m dimension to a WKB type and returns the new type

addZ

Adds the z dimension to a WKB type and returns the new type

coordDimensions

Returns the coordinate dimension of the geometry type as an integer.

curveType

Returns the curve type for a WKB type.

displayString

Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.

dropM

Drops the m dimension (if present) for a WKB type and returns the new type.

dropZ

Drops the z dimension (if present) for a WKB type and returns the new type.

flatType

Returns the flat type for a WKB type.

geometryDisplayString

Returns a display string for a geometry type.

geometryType

Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a PolygonGeometry geometry type.

hasM

Tests whether a WKB type contains m values.

hasZ

Tests whether a WKB type contains the z-dimension.

isCurvedType

Returns True if the WKB type is a curved type or can contain curved geometries.

isMultiType

Returns True if the WKB type is a multi type.

isSingleType

Returns True if the WKB type is a single type.

linearType

Returns the linear type for a WKB type.

multiType

Returns the multi type for a WKB type.

parseType

Attempts to extract the WKB type from a WKT string.

promoteNonPointTypesToMulti

Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types.

singleType

Returns the single type for a WKB type.

to25D

Will convert the 25D version of the flat type if supported or Unknown if not supported.

translatedDisplayString

Returns a translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.

wkbDimensions

Returns the inherent dimension of the geometry type as an integer.

zmType

Returns the modified input geometry type according to hasZ / hasM

Attributes

staticMetaObject

class GeometryType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.IntEnum

The geometry types are used to group Qgis.WkbType in a coarse way.

Note

Prior to 3.30 this was available as QgsWkbTypes.GeometryType.

Added in version 3.30.

  • PointGeometry: Points

  • LineGeometry: Lines

  • PolygonGeometry: Polygons

  • UnknownGeometry: Unknown types

  • NullGeometry: No geometry

baseClass

alias of Qgis

Type

alias of WkbType

addM(type: Qgis.WkbType) Qgis.WkbType

Adds the m dimension to a WKB type and returns the new type

Parameters:

type (Qgis.WkbType) – original type

See also

addZ()

See also

dropM()

See also

hasM()

Return type:

Qgis.WkbType

addZ(type: Qgis.WkbType) Qgis.WkbType

Adds the z dimension to a WKB type and returns the new type

Parameters:

type (Qgis.WkbType) – original type

See also

addM()

See also

dropZ()

See also

hasZ()

Return type:

Qgis.WkbType

coordDimensions(type: Qgis.WkbType) int

Returns the coordinate dimension of the geometry type as an integer. Returned value will be between 2-4, depending on whether the geometry type contains the Z or M dimensions. Invalid geometry types will return a dimension of 0.

See also

wkbDimensions()

Parameters:

type (Qgis.WkbType)

Return type:

int

curveType(type: Qgis.WkbType) Qgis.WkbType

Returns the curve type for a WKB type. For example, for Polygon WKB types the curve type would be CurvePolygon.

Note

Returns CompoundCurve for CircularString (and its Z/M variants)

See also

linearType()

See also

isMultiType()

See also

isCurvedType()

See also

singleType()

See also

flatType()

See also

multiType()

Added in version 3.10.

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

displayString(type: Qgis.WkbType) str

Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.

Parameters:

type (Qgis.WkbType)

Return type:

str

dropM(type: Qgis.WkbType) Qgis.WkbType

Drops the m dimension (if present) for a WKB type and returns the new type.

Parameters:

type (Qgis.WkbType) – original type

See also

dropZ()

See also

addM()

Return type:

Qgis.WkbType

dropZ(type: Qgis.WkbType) Qgis.WkbType

Drops the z dimension (if present) for a WKB type and returns the new type.

Parameters:

type (Qgis.WkbType) – original type

See also

dropM()

See also

addZ()

Return type:

Qgis.WkbType

flatType(type: Qgis.WkbType) Qgis.WkbType

Returns the flat type for a WKB type. This is the WKB type minus any Z or M dimensions. For example, for PolygonZM WKB types the single type would be Polygon.

See also

singleType()

See also

multiType()

See also

curveType()

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

geometryDisplayString(type: Qgis.GeometryType) str

Returns a display string for a geometry type.

This will return one of the following strings:

  • Point

  • Line

  • Polygon

  • Unknown Geometry

  • No Geometry

  • Invalid Geometry

Parameters:

type (Qgis.GeometryType)

Return type:

str

geometryType(type: Qgis.WkbType) Qgis.GeometryType

Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a PolygonGeometry geometry type. GeometryCollections are reported as Qgis.GeometryType.Unknown.

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.GeometryType

hasM(type: Qgis.WkbType) bool

Tests whether a WKB type contains m values.

Return type:

bool

Returns:

True if type has m values

See also

addM()

See also

hasZ()

Parameters:

type (Qgis.WkbType)

hasZ(type: Qgis.WkbType) bool

Tests whether a WKB type contains the z-dimension.

Return type:

bool

Returns:

True if type has z values

See also

addZ()

See also

hasM()

Parameters:

type (Qgis.WkbType)

isCurvedType(type: Qgis.WkbType) bool

Returns True if the WKB type is a curved type or can contain curved geometries.

Parameters:

type (Qgis.WkbType)

Return type:

bool

isMultiType(type: Qgis.WkbType) bool

Returns True if the WKB type is a multi type.

See also

isSingleType()

See also

multiType()

Parameters:

type (Qgis.WkbType)

Return type:

bool

isSingleType(type: Qgis.WkbType) bool

Returns True if the WKB type is a single type.

See also

isMultiType()

See also

singleType()

Parameters:

type (Qgis.WkbType)

Return type:

bool

linearType(type: Qgis.WkbType) Qgis.WkbType

Returns the linear type for a WKB type. For example, for a CompoundCurve, the linear type would be LineString.

See also

curveType()

See also

isMultiType()

See also

isCurvedType()

See also

singleType()

See also

flatType()

See also

multiType()

Added in version 3.14.

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

multiType(type: Qgis.WkbType) Qgis.WkbType

Returns the multi type for a WKB type. For example, for Polygon WKB types the multi type would be MultiPolygon.

See also

isMultiType()

See also

singleType()

See also

curveType()

See also

flatType()

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

parseType(wktStr: str | None) Qgis.WkbType

Attempts to extract the WKB type from a WKT string.

Parameters:

wktStr (Optional[str]) – a valid WKT string

Return type:

Qgis.WkbType

promoteNonPointTypesToMulti(type: Qgis.WkbType) Qgis.WkbType

Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types.

Specifically, this method should be used to determine the most-permissive possible resultant WKB type which can result from subtracting parts of a geometry. A single-point geometry type can never become a multi-point geometry type as a result of a subtraction, but a single-line or single-polygon geometry CAN become a multipart geometry as a result of subtracting portions of the geometry.

See also

multiType()

See also

singleType()

Added in version 3.24.

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

singleType(type: Qgis.WkbType) Qgis.WkbType

Returns the single type for a WKB type. For example, for MultiPolygon WKB types the single type would be Polygon.

See also

isSingleType()

See also

multiType()

See also

curveType()

See also

flatType()

Parameters:

type (Qgis.WkbType)

Return type:

Qgis.WkbType

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
to25D(type: Qgis.WkbType) Qgis.WkbType

Will convert the 25D version of the flat type if supported or Unknown if not supported.

Parameters:

type (Qgis.WkbType) – The type to convert

Return type:

Qgis.WkbType

Returns:

the 25D version of the type or Unknown

translatedDisplayString(type: Qgis.WkbType) str

Returns a translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.

Added in version 3.18.

Parameters:

type (Qgis.WkbType)

Return type:

str

wkbDimensions(type: Qgis.WkbType) int

Returns the inherent dimension of the geometry type as an integer. Returned value will always be less than or equal to the coordinate dimension.

Return type:

int

Returns:

0 for point geometries, 1 for line geometries, 2 for polygon geometries Invalid geometry types will return a dimension of 0.

Parameters:

type (Qgis.WkbType)

zmType(type: Qgis.WkbType, hasZ: bool, hasM: bool) Qgis.WkbType

Returns the modified input geometry type according to hasZ / hasM

Parameters:
Return type:

Qgis.WkbType