Geometry functions in Context

“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.

You try:

Goal: To learn how to use the geometry functions to label polygons

  • Load the data
  • Symbolise the vector layer using the values defined in the table.
  • Add a background layer i.e webmap.
  • Go to label settings and add a rule based label.
  • Give your rule a name and under Labels choose label with Expression and use the label_text.

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?

  • Click on the placement settings and choose data defined setting.
  • Click on the X and choose edit from the drop-down that appears.
  • Insert the expression x_cord in the dialogue.
  • Repeat the previous step using Y and determine what function to use.
  • Add another rule and label with the location_text.
  • On the placement use 'Permiter'.
    Click on the text and choose size. Use data defined and select edit and enter the text_size expression.

Name Expectation

Vector stle

Fill type = transparent, outline style =dash line


round($area ) ,3 ) || ' metres'




substr( location,1,6 ) || ' ' || substr( location,8,8)

More about

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.

Check your knowledge:

  1. What is a geometry function:
    1. A type of vector data.
    2. A type of symbology mechanism that can be used for rasters and vector layers.
    3. A type of function that allows new values to be computed based on existing geometry of the layer.
  2. When using the geometry functions to calculate area does the data need to be in a projected co ordinate reference system:
    1. Yes, you can only get accurate area interpretation when the data is projected.
    2. No, A GIS should be able to handle this.
    3. I do not know.
  3. Can you use geometry functions with raster layers:
    1. True
    2. False