[GIS] How to force QGIS Centroid Fill inside the Polygon

centroidsqgis

I would like to use a centroid fill to enable me to place a letter inside a polygon. The advantage of using a centroid fill is that it also shows up in a legend, whereas labelling the layer would mean I have to put a text label on the legend in the composer.

The problem I have with the centroid fill is that the centroid can fall outside of the polygon, and as such my letter will not be within the polygon I need it to be.

I have included an example that shows where the centroid fills have worked, and one where it hasn't (the label shown in red):

enter image description here

Is there a way to force the centroid fill to be inside of the polygon?

Or is there another way to achieve this?

Best Answer

I've only found this work-around so far:

  1. You need to load the polygon layer twice.
  2. The lower layer is styled using the Centroid Fill option.
  3. The upper layer uses the same style but without the Centroid Fill layer.
  4. Enable labeling for the upper layer. Placement should be 'horizontal' or 'free'.
  5. In Print Composer, delete the upper layer from the legend items list.

This is far from optimal, but I don't think this special feature is going to be implemented soon into the renderer.

enter image description here

Related Question