[Qgis-user] Offsetting rotated labels proportionate to variable angles/rotations

Marco Casalboni casalbonim at gmail.com
Tue Jul 6 06:05:51 PDT 2021


I had the same problem.
I imported a .sld file from geoserver to qgis and it seems some (or many)
things are different.
The worst of all is the algorithm applied for rototranslation.
Apparently, the offset x, y and the rotation (or data defined rotation)
fields, don't work together in a rototranslation function. Searching until
something like the 10th page on google and merging every little piece in as
many forums, I found out if you have to apply a rototranslation
data-defined formula, you must set up some things manually.
First of all, you have to set up the data-defined rotation field,
remembering that, for some reasons, the angle is shifted by 90 degrees.
Then you have to place the rotated label in a coordinate computed by the
 real  rototranslation formula (rotation and translation combined). To do
that, I find this formula to output the best results, in the Offset X, Y
field:

concat (
-A * sin ((90 - "field") * pi () / 180) -B * cos ((90 - "field") * pi () /
180),
',',
A * cos ((90 - "field") * pi () / 180) -B * sin ((90 - "field") * pi () /
180)
)

where A and B are 2 constants for offset and "field" is your data-defined
field

Sorry if something is unclear, this method is a quite unfriendly way to
accomplish this need

Marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210706/94e3895d/attachment.html>


More information about the Qgis-user mailing list