[Qgis-developer] Python: drop z/m values

Hugo Mercier hugo.mercier at oslandia.com
Tue Mar 29 23:37:37 PDT 2016


Hi,

On 29/03/2016 13:00, Tom Chadwin wrote:
> Currently, I detect the geometry type of input layers (which the user
> supplies, so they could be anything) with layer.wkbType(). This fails
> (returning -2147483646) if the input layer has z/m values (and will probably
> also fail with eg curved geometries).

-2147483646 is actually QGis.WKBLineString25D, so this is the right
answer :)
But this is going to be removed in the future in favor of QgsWKBTypes

> 
> Is there a way to "flatten/simplify" newer/more complex geometry types into
> simple point/line/poly types?

>From QgsVectorLayer, you can call geometryType().

>From a QGis.WkbType you can call QGis.flatType()

You can also convert a QGis.WkbType to a (new) QgsWkbTypes with
QGis.fromOldWkbType and have access to QgsWkbTypes.flatType()



More information about the Qgis-developer mailing list