Project: QGIS

Version: 3.4 LTR

Feature: New expression functions and variables

Many new expression functions have been added in QGIS 3.4. These include many handy functions for working with and manipulating arrays and maps (dictionary) objects.

  • json_to_map: Converts a JSON encoded string value to a map (dictionary) type object
  • map_to_json: Converts a map (dictionary) type object to a JSON encoded string value
  • hstore_to_map: Converts a hstore value to a map (dictionary) type object
  • map_to_hstore: Converts a map (dictionary) type object to a hstore value
  • array_foreach : Loops over an array and executes an expression on each item in the array, returning a new array containing each calculated value
  • array_filter : Filters an array according to an expression
  • raster_value: Returns a value sampled from a raster layer at a specified point
  • to_dms: Converts a numeric value to a Degrees, Minutes, Seconds formatted string
  • to_dm: Converts a numeric value to a Degrees, Minutes formatted string
  • line_substring: Returns the portion of a line (or curve) geometry which falls between the specified start and end distances (measured from the beginning of the line). Z and M values are linearly interpolated from existing values.
  • generate_series(start,stop,step): creates an array containing a sequence of numbers.

Additionally, some new variables have also been made available for use within QGIS expressions:

  • @canvas_cursor_point: Contains a point value representing the current position of the mouse cursor within the main map canvas
  • @map_layers: Contains an array of all layers which are visible within the map
  • @map_layer_ids: Contains an array of all layer IDs for layers visible within the map