2

I am working with a tax lot shapefile with attributes such as ownership, addresses, account numbers, etc. I am trying to create a map with the ownership name of each polygon. My problem is that some of the polygons are huge and some are small, so when I go to my print layout page with those labels turned on, the large polygons have a tiny bit of text in them and the small polygons have text that falls outside of it's boundaries.

I would assume a simple if else statement would fix something like this. Though I am not sure how to do and if else statement for a label nor have any experience using python within QGIS if that is the route for this problem. Could someone help guide me though this process?

enter image description here

3

To add another option to @TeddyTedTed answer You may use the scale_linear (or scale exp) fonction :

function scale_linear Transforms a given value from an input domain to an output range using linear interpolation.

(the scale_exp fonction do the same but using an exponential curve)

This will give you a big range of text size without having to input many many case statement.

For exemple this expression (based on a "SHAPE-AREA" field that hold the polygon area, it will also work if you use $area) :

scale_linear( "SHAPE_AREA" , minimum(  "SHAPE_AREA" ), maximum(  "SHAPE_AREA" ) ,1,100)

attribute a text size between 1 and 100 relative to the area, 1 for the smallest area and an increasing value as the area grow, up to a text size of 100 the largest area.

enter image description here

1
  • Thanks. I do like this way a bit more, without having to to multiple CASE functions. – Zman3 Oct 8 '20 at 17:51
3

You're on the right track with if else but case would be easier, it's similar to if else but easier for more options.

In expressions $area returns the area of a polygon in square metres or feet depending on the coordinate system.

So we use case to create different label sizes depending on the $area value for the polygons.

In the label properties add an expression for the size: enter image description here

As the expression write something like the following but with area classes that make sense for your parcels:

CASE
WHEN $area <15000 THEN 6
WHEN $area >=15000 AND $area < 20000 THEN 8
WHEN $area >=20000 AND $area < 50000 THEN 10
WHEN $area >=50000 AND $area < 100000 THEN 12
WHEN $area >=100000 THEN 14
END

In my example this resulted in the following (the values are the $area values for each parcel):

enter image description here

2
  • 1
    Excellent, I will give this a try later today and accept the answer once I get it to work! – Zman3 Oct 7 '20 at 23:26
  • 1
    Thanks again for your suggestion. I am going to go with J.R answer since it is simpler. – Zman3 Oct 8 '20 at 17: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.