I have a problem setting angled text labels with the new-style labelling dialog. The situation is this:

I have a shape file which only contains only labelling texts. This is a point layer, and it contains all information needed for the label, like text size, font etc. - while the placement of the label is steered by the cordinates of the geometry of the point, so there are no attributes containing the X and y coordinate. This is legacy data, so I have no choice in the matter - the labels aren't linked to objects in other shapefiles, they're just there by themselves, having originally made up a separate toponym layer.

If I use the old labelling mechanism, I can enter the text angle field in the appropriate place (in my data it's called TextAngle), and the text is displayed at the desired angle. But if I use the new-style labelling dialog, the text angle field in the 'position' section of the 'data defined settings' tab remains greyed out unless I set the fields 'x-coordinate' and 'y-coordinate'. Yet I don't have fields containing x and y coordinates in my data - they are implicit, being the very coordinates my data points occupy. They appear when I get info for the elements as 'derived', but they aren't in the attribute table. If I try and trick the dialog by entering something else in the 'x-coordinate' and 'y-coordinate' fields, I can enter my text angle field, but it has no effect.

Am I missing something? I'd really rather use the new-style labelling, since the buffering is nicer.

3 Answers 3


In fact, it's very easy to add x-ordinate and y-ordinate columns automatically to the attribute table of a point shapefile: Vector -> Geometry Tools -> Export/Add geometry columns.

  • Having tried this solution and also the one proposed by underdark I found they both work. Thanks! But I have over 1000 of these shape files. Is there a command line tool to do the same thing? May 13, 2012 at 15:40

Currently it's not possible to rotate new labels without specifying the x/y position. It's one (if not the) major blocker for removing old labeling engine.

You can add explicit x and y attributes using Field Calculator $x and $y operators as a work-around.

  • Having browsed the thread you link to, I think that noone seems to make much of this problem. Yet in a point layer it is absurd to ask for x- and y-coordinates - this only makes sense in line and polygon layers. On the other hand, if the layer in question is a point layer, the x- and y-coordinate is defined and shouldn't be too hard to acquire (say I, not having looked at the code) May 13, 2012 at 8:23

I found a python module to do the job. It's called shapefile.py and I found it at


Using this module, adding the x and y coordinate as attributes was quite straightforward. I wrote a little script called add_xy.py:

#! /bin/python

import sys
import shapefile

sf = shapefile.Reader(sys.argv[1])
shapeRecs = sf.shapeRecords()
fields.append ( ['x-coord', 'F', 19, 11] )
fields.append ( ['y-coord', 'F', 19, 11] )
w = shapefile.Writer(shapefile.POINT)
for f in fields:
w.field (*f)
for r in shapeRecs:
for r in shapeRecs:
    w.point ( *r.shape.points[0] )
for r in shapeRecs:
    w.record ( *r.record )

I called this like

python add_xy.py input.shp output

Now when I load output.shp into QGIS, I have the additional coordinate fields and I can use the angle defined in the data. Bit of a circuitious route, but it works :)

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.