Class: QgsWkbTypes

Handles storage of information regarding WKB types and their properties.

class qgis.core.QgsWkbTypes[source]

Bases: object

class GeometryType(*values)

Bases: 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.

  • Point: Points

    Available as QgsWkbTypes.PointGeometry in older QGIS releases.

  • Line: Lines

    Available as QgsWkbTypes.LineGeometry in older QGIS releases.

  • Polygon: Polygons

    Available as QgsWkbTypes.PolygonGeometry in older QGIS releases.

  • Unknown: Unknown types

    Available as QgsWkbTypes.UnknownGeometry in older QGIS releases.

  • Null: No geometry

    Available as QgsWkbTypes.NullGeometry in older QGIS releases.

Type

alias of WkbType

static addM(type: Qgis.WkbType) Qgis.WkbType[source]

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

static addZ(type: Qgis.WkbType) Qgis.WkbType[source]

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

static coordDimensions(type: Qgis.WkbType) int[source]

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

static curveType(type: Qgis.WkbType) Qgis.WkbType[source]

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

static displayString(type: Qgis.WkbType) str[source]

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

static dropM(type: Qgis.WkbType) Qgis.WkbType[source]

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

static dropZ(type: Qgis.WkbType) Qgis.WkbType[source]

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

static flatType(type: Qgis.WkbType) Qgis.WkbType[source]

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

static geometryDisplayString(type: Qgis.GeometryType) str[source]

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

static geometryType(type: Qgis.WkbType) Qgis.GeometryType[source]

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

static hasM(type: Qgis.WkbType) bool[source]

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)

static hasZ(type: Qgis.WkbType) bool[source]

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)

static isCurvedType(type: Qgis.WkbType) bool[source]

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

Parameters:

type (Qgis.WkbType)

Return type:

bool

static isMultiType(type: Qgis.WkbType) bool[source]

Returns True if the WKB type is a multi type.

See also

isSingleType()

See also

multiType()

Parameters:

type (Qgis.WkbType)

Return type:

bool

static isSingleType(type: Qgis.WkbType) bool[source]

Returns True if the WKB type is a single type.

See also

isMultiType()

See also

singleType()

Parameters:

type (Qgis.WkbType)

Return type:

bool

static linearType(type: Qgis.WkbType) Qgis.WkbType[source]

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

static multiType(type: Qgis.WkbType) Qgis.WkbType[source]

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

static parseType(wktStr: str | None) Qgis.WkbType[source]

Attempts to extract the WKB type from a WKT string.

Parameters:

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

Return type:

Qgis.WkbType

static promoteNonPointTypesToMulti(type: Qgis.WkbType) Qgis.WkbType[source]

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

static singleType(type: Qgis.WkbType) Qgis.WkbType[source]

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

static to25D(type: Qgis.WkbType) Qgis.WkbType[source]

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

static translatedDisplayString(type: Qgis.WkbType) str[source]

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

static wkbDimensions(type: Qgis.WkbType) int[source]

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)

static zmType(type: Qgis.WkbType, hasZ: bool, hasM: bool) Qgis.WkbType[source]

Returns the modified input geometry type according to hasZ / hasM

Parameters:
Return type:

Qgis.WkbType