2

I am attempting to recreate a layout from ArcGIS in QGIS. One of the advanced label options in ArcGIS is to force horizontal labels outside a polygon. You can optionally choose which quadrant the labels fall in.
Horizontal label outside polygon - ArcGIS

This question is related, but the labels are parallel with the polygon perimeter: Labels outside polygons in ArcMap

The answer to this question is basically what I'm looking for, but my polygons aren't circles: Upright/Horizontal labels when labeling polygons at perimeter in QGIS That question was asked in 2014, so perhaps a solution has been found in ensuing years? I am fine with prioritizing a quadrant for location, if that would help.

3

I'm using QGIS 2.18.4

You can create a virtual layer importing your polygons by a buffer distance (and keeping your label field):

enter image description here

And then label like this:

enter image description here

You will end up with this (I'm adding the buffer outline so you can see it but you can set it to transparent):

enter image description here

2

If I understand correctly, you can do like this:

enter image description here

Keep in mind that using curved labels will not show up too long laybels.

2

Unfortunately, there is no automatic way to place the labels outside the polygons and keep them horizontally. After several tests, I found two ways to do that, but both of them are time consuming:

  1. Using Rule based Labeling

    • You to define each label individually, and use Placement -> Data Defined -> Coordinate X and enter the following formula:

      x(bounds($geometry))+ Constant
      

      Placement -> Data Defined -> Coordinate y and enter the following formula:

      y(bounds($geometry))+ Constant
      

      Where constant is an offset value to shift the label outside the polygon, thus, you need to adjust the constant for each individual label.

    • I used Alignment horizontal and vertical and wrote 'Center'and 'Cap', respectively.

enter image description here

Here is the result:

enter image description here

  1. The second option is to add x and y fields in the attribute table, then go to Placement -> Data Defined -> Coordinate X and Coordinate y, and select x field and y field, respectively. Then start editing and move the labels manually outside each polygon.

As I said at the top of my answers, both solutions are not efficient. But I hope the developer team can add this option in the next releases.

  • This is the same as in the first answer I referenced. I do not want to follow the curvature, but to have the labels horizontal, as similar to the 2nd link I referenced. That answer doesn't work though because my polygons are not circles. – Get Spatial Mar 30 '17 at 3:19
  • I misunderstood your question, I thought you want the labels to follow the curvature of the polygon. – ahmadhanb Mar 30 '17 at 3:35
  • I updated my answer. – ahmadhanb Apr 3 '17 at 6:01

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.