How could I set LinePlacementFlags with Python in QGIS? My code is something like:

palyr = QgsPalLayerSettings()
palyr.enabled = True
palyr.fieldName = "attribute"

Then I've tried:

palyr.placement= QgsPalLayerSettings.Line

And my labels are on the line. I want them above the line, but I can't figure how to do this. I found there is LinePlacementFlags type. But

palyr.LinePlacementFlags= QgsPalLayerSettings.AboveLine

didn't work.


You're looking for placementFlags. So,

palyr.placementFlags = QgsPalLayerSettings.AboveLine

should work. Note that LinePlacementFlags can be combined, so

palyr.placementFlags = QgsPalLayerSettings.AboveLine | QgsPalLayerSettings.BelowLine 

will allow labels above and below the line, but not on over the line.

| improve this answer | |

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.