2

I'm trying to label features using the geometry generator (QGIS 3.8). I used the following expression to build a simple circle :

buffer(centroid($geometry), 500)

In Placement i used Using Perimeter (curved)

The labeling is working pretty good except some of my features label are written clockwise and some counterclockwise. How could i control this rendering ?

Furthermore i would like the mid-point of my labeling string to be at the most northern point of the circle ...

How could i achieve that ?

2

For clockwise/counterclockwise fix, you can allow upside-down labels. In label rendering tab set Show upside-down labels to allways.

enter image description here

For centering the label to the north, I figure out a workaround based on Using QGIS Geometry Generator to get rectangle from point?. Using geometry generator in label placement tab, you can create buffer of tiny polygon witch starts at such a place that the label is then rendered on top. Just adjust the buffer size to your needs.

buffer(geom_from_wkt( 
    'POLYGON(('|| 
        (x(centroid($geometry)))||' '||(y(centroid($geometry)) - 0.0001) ||','||
        (x(centroid($geometry)))||' '||(y(centroid($geometry)) + 0.0001) ||','||
        (x(centroid($geometry)) + 0.0001)||' '||(y(centroid($geometry)) - 0.0001) ||','||
    '))'
    ),
    0.3
)

enter image description here

Note that geometry generator for label placement is available from version QGIS 3.8

  • So where do you put that buffer expression? Do you add a geometry generator symbol layer? – csk Oct 14 at 15:54
  • @csk No, in version 3.8 is geometry generator also for label placement (in Labels -> Placement tab) – Oto Kaláb Oct 14 at 18:06
  • It might be worth mentioning that in your answer, otherwise people using the current LTR will have trouble understanding your answer. – csk Oct 15 at 15:47
  • Yes, but I followed the OP, where is mention use of geometry generator for label placement in version QGIS 3.8. For completeness, I added note to my answer. – Oto Kaláb Oct 15 at 17:33
  • @Oto i'm using indeed qgis 3.8 but i'm struggling using your expression ... where should i put it ? is it supposed to replace my former buffer(centroid($geometry),500)? how would my text be bended in that case ? What kind of units should be used in such expression ? – snaileater Oct 15 at 18:52

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.