“The field calculator allows for manipulating fields and values”
The geometry functions are special type of functions which are used to manipulate the geometry of layers. The geometry functions can be used in multiple places like labeling and symbology.
In this module, we will look at how we can use the geometry functions in labeling features.
Goal: To learn how to use the geometry functions to label polygons
NB: Change the label_text to show the area in hectares and replace metres with 'ha'
What is the use of the labelling function above?
Name | Expectation |
---|---|
Vector stle |
Fill type = transparent, outline style =dash line |
label_col |
round($area ) ,3 ) || ' metres' |
size_exp |
rand(8,14) |
location_label |
substr( location,1,6 ) || ' ' || substr( location,8,8) |
Geometry functions are very useful as they allow on the fly computation of values. This reduces the need to have to create multiple layers or attributes to hold certain values. When using the geometry functions in labelling you have to take into consideration the number of features that are in the layer as this tends to make it slow.
Example: x(line_interpolate_point($geometry,0.7*$length))
The function above places a label at 70 % of the length of the line. Geometry functions adds capabilities for defining the placement of labels.