I want to find out the wkbType of a layer, this is my code:

print layer.wkbType()

Usually when it is a line geometry layer, it would give me 2. But instead it is giving me -2147483646.

enter image description here


The 2.5D types has such values:

wkbPoint25D = -2147483647,   /* 2.5D extensions as per 99-402 */
wkbLineString25D = -2147483646,
wkbPolygon25D = -2147483645,
wkbMultiPoint25D = -2147483644,
wkbMultiLineString25D = -2147483643,
wkbMultiPolygon25D = -2147483642,
wkbGeometryCollection25D = -2147483641

To strip 2.5D from geometry you can use:


To get geometry name:


And full python example:

>>> from osgeo import ogr
>>> ogr.GT_Flatten(-2147483646)
>>> ogr.GeometryTypeToName(-2147483646)
'3D Line String'
  • Or QgsWkbTypes.flatType to stay within one library. – Matthias Kuhn Aug 27 '17 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.