I just upgraded to qgis 2.2 from 2.0. In 2.2 there was a minor change to data defined label positioning at least when used with postgis layers.

In Version 2.2 the labeling engine appears to be treating null values in labelX and labelY as 0 instead of null. It is also doing this in the feature form, but not when I view the Attribute table. The result of this is that when I have data defined label positioning turned on and I save a feature without moving the label the label is rendered at 0,0 instead of at the feature centroid.

In postgis I have my label coordinates defined as real and qgis is treating them as a double float4. After looking at another thread I loaded the same label coordinates as first a String, and second as an Integer. My labels behaved properly when I had the coordinates defined as strings.

Is there any way to fix this problem by changing a setting within QGIS?

My options currently appear to be either changing all of my label data types to strings or writing trigger functions to populate my label position fields with the centroid of each polygon.

1 Answer 1


I had exactly the same problem when i upgraded to 2.2.

This work fine : Instead of use directly the "labelX" field, you can use this espression for the X value :

case when "labelX" is not null then  "labelX" else null end

No need to repeat for the Y value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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