Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active June 21, 2020 10:52
Show Gist options
  • Select an option

  • Save ThomasG77/0c6862fb2b6b3fc301ea994733688ea5 to your computer and use it in GitHub Desktop.

Select an option

Save ThomasG77/0c6862fb2b6b3fc301ea994733688ea5 to your computer and use it in GitHub Desktop.
Script to write QGIS expressions on one page (easy to reference to help people on the web, text search from your browser) https://gist.githack.com/ThomasG77/0c6862fb2b6b3fc301ea994733688ea5/raw/99ecc5e6127e7238814da330a4d5d0b9fa2afe4e/qgis-3-12-expressions-single-page.html

Generate single page documentation for expressions

Why?

The goal was a single page documentation on expression

One approach could have been about using scripts/process_function_template.py and/or files in resources/function_help/json/. As there is no link between groups and functions documented in these json files, you need to look for the relation in the source src/core/expression/qgsexpressionfunction.cpp. You would also need to manage translations. FYI, all paths are relative to the root of the source code repo.

So, instead we've made the choice to use HTML generated doc for expressions from PyQGIS docs. It works for any languages

How to

You need to install third party Python library BeautifulSoup4 into the version of Python used by QGIS. For Linux, do it with

pip install beautifulsoup4

Then, run the script pyqgis-list-expressions.py within PyQGIS console.

As the script is generated dynamically within QGIS and we need to change the locale each time we want to generate a new lang doc, we only produced some translations. Feel free to ask in the comments for another languages.

Current generated docs

import itertools
from bs4 import BeautifulSoup
from qgis.core import Qgis
unique_groups = set(itertools.chain.from_iterable([fct.groups() for fct in QgsExpression.Functions() if ('deprecated' not in fct.groups() and 'Custom' not in fct.groups())]))
unique_sorted_groups = sorted(unique_groups)
functions_list_no_deprecated = [[
fct.name(),
fct.groups(),
BeautifulSoup(QgsExpression.helpText(fct.name())).prettify() # Sanitize HTML to fix unbalalanced tags
] for fct in QgsExpression.Functions() if ('deprecated' not in fct.groups() and 'Custom' not in fct.groups())]
sorted_functions = sorted(functions_list_no_deprecated)
# Styles excerpt from QGIS CSS internal styles
styles = '''
.overview{
font: 1.82em;
font-weight: bold;
}
body{
background: white;
color: black;
font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;
width: 100%;
}
h1{
background-color: #F6F6F6;
color: #589632;
font-size: x-large;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 3em;
}
h2{
background-color: #F6F6F6;
color: #589632;
font-size: medium;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 1.1em;
}
h3{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: large;
text-align: left;
border-bottom: 5px solid #DCEB5C;
}
h4{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: medium;
text-align: left;
}
h5{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: small;
text-align: left;
}
a{
color: #729FCF;
font-family: arial,sans-serif;
}
label{
background-color: #FFFFCC;
border: 1px solid black;
margin: 1px;
padding: 0px 3px;
font-size: small;
}
th .strong {
font-weight: bold;
}
hr {
border: 0;
height: 0;
border-top: 1px solid black;
}
.list-view .highlight {
text-align: left;
border: 0px;
width: 20%;
padding-right: 15px;
padding-left: 20px;
font-weight: bold;
}
.tabular-view .odd-row {
background-color: #f9f9f9;
}
.section {
font-weight: bold;
padding-top:25px;
}
.tabular-view{
border-collapse: collapse;
width: 95%;
}
.tabular-view th, .tabular-view td {
border:10px solid black;
}
.overview{
font: 1.82em;
font-weight: bold;
}
body{
background: white;
color: black;
font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;
width: 100%;
}
h1{
background-color: #F6F6F6;
color: #589632;
font-size: x-large;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 3em;
}
h2{
background-color: #F6F6F6;
color: #589632;
font-size: medium;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 1.1em;
}
h3{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: large;
text-align: left;
border-bottom: 5px solid #DCEB5C;
}
h4{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: medium;
text-align: left;
}
h5{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: small;
text-align: left;
}
a{
color: #729FCF;
font-family: arial,sans-serif;
}
label{
background-color: #FFFFCC;
border: 1px solid black;
margin: 1px;
padding: 0px 3px;
font-size: small;
}
th .strong {
font-weight: bold;
}
hr {
border: 0;
height: 0;
border-top: 1px solid black;
}
.list-view .highlight {
text-align: left;
border: 0px;
width: 20%;
padding-right: 15px;
padding-left: 20px;
font-weight: bold;
}
.tabular-view .odd-row {
background-color: #f9f9f9;
}
.section {
font-weight: bold;
padding-top:25px;
}
'''
overloaded_style = '''
body {
margin-left: 50px;
}
.group {
margin-bottom: 30px;
}
.function {
margin-left: 20px;
}
'''
content = []
toc = []
for group in unique_sorted_groups:
anchor_group_id = group.lower().replace(' ', '-')
# Not enough generic but did not found better way...
if group == 'Form':
group_locale_name = QgsApplication.translate("Form", "Form")
elif group == 'Layout':
group_locale_name = QgsApplication.translate("QObject", "Layout")
elif group == 'GeometryGroup':
group_locale_name = QgsApplication.translate("QgsExpression", "Geometry")
else:
group_locale_name = QgsApplication.translate("QgsExpression", group)
mygroup = {
'name': group,
'locale_name': group_locale_name,
'id': anchor_group_id,
'functions': []
}
content.append('<div id="' + anchor_group_id + '" class="group">' +
QgsExpression.helpText(group).replace('<h3>', '<h2><a href="#' + anchor_group_id + '-idx' + '">').replace('</h3>', '</a></h2>') + '</div>')
# content.append(QgsExpression.helpText(group).replace('h3', 'h2'))
for fct in sorted_functions:
if group in fct[1]:
anchor_function_name = fct[0].lower().replace(' ', '-').replace('$', 'dollar-')
anchor_function_id = anchor_group_id + '-' + anchor_function_name
mygroup['functions'].append({
'name': fct[0],
'id': anchor_function_id
})
content.append(
'<div class="function">' + fct[2].replace('<h3>', '<h3 id="{}"><a href="#{}">'.format(anchor_function_id, anchor_function_id + '-idx')).replace('</h3>', '</a></h3>') + '</div>'
)
toc.append(mygroup)
html_toc = ''.join([
'<a href="#' + group['id'] +'">' + '<h2 id="' + group['id'] + '-idx' +'">' + group['locale_name'] + "</h2>" + "</a>" +
"<ul>" + ''.join([
'<li>' + '<a href="#' + fct['id'] + '">' + '<span id="' + fct['id'] + '-idx' + '">' + fct['name'] + '</span>' + "</a>" + "</li>" for fct in group['functions']
]) + "</ul>" for group in toc
])
content = ["<style>{}</style>".format(styles + overloaded_style)] + ["<h1>Expressions documentation single page (locale " + QgsApplication.locale() + ")</h1>"] + [html_toc] + content
with open('/tmp/qgis-' + '-'.join(Qgis.QGIS_VERSION.split('.')[0:2]) + '-' + QgsApplication.locale() + '-expressions-single-page.html', 'w') as f:
f.write('\n'.join(content))
<style>
.overview{
font: 1.82em;
font-weight: bold;
}
body{
background: white;
color: black;
font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;
width: 100%;
}
h1{
background-color: #F6F6F6;
color: #589632;
font-size: x-large;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 3em;
}
h2{
background-color: #F6F6F6;
color: #589632;
font-size: medium;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 1.1em;
}
h3{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: large;
text-align: left;
border-bottom: 5px solid #DCEB5C;
}
h4{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: medium;
text-align: left;
}
h5{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: small;
text-align: left;
}
a{
color: #729FCF;
font-family: arial,sans-serif;
}
label{
background-color: #FFFFCC;
border: 1px solid black;
margin: 1px;
padding: 0px 3px;
font-size: small;
}
th .strong {
font-weight: bold;
}
hr {
border: 0;
height: 0;
border-top: 1px solid black;
}
.list-view .highlight {
text-align: left;
border: 0px;
width: 20%;
padding-right: 15px;
padding-left: 20px;
font-weight: bold;
}
.tabular-view .odd-row {
background-color: #f9f9f9;
}
.section {
font-weight: bold;
padding-top:25px;
}
.tabular-view{
border-collapse: collapse;
width: 95%;
}
.tabular-view th, .tabular-view td {
border:10px solid black;
}
.overview{
font: 1.82em;
font-weight: bold;
}
body{
background: white;
color: black;
font-family: 'Lato', 'Ubuntu', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;
width: 100%;
}
h1{
background-color: #F6F6F6;
color: #589632;
font-size: x-large;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 3em;
}
h2{
background-color: #F6F6F6;
color: #589632;
font-size: medium;
font-weight: normal;
background: none;
padding: 0.75em 0 0;
margin: 0;
line-height: 1.1em;
}
h3{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: large;
text-align: left;
border-bottom: 5px solid #DCEB5C;
}
h4{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: medium;
text-align: left;
}
h5{
background-color: #F6F6F6;
color: #93b023;
font-weight: bold;
font-size: small;
text-align: left;
}
a{
color: #729FCF;
font-family: arial,sans-serif;
}
label{
background-color: #FFFFCC;
border: 1px solid black;
margin: 1px;
padding: 0px 3px;
font-size: small;
}
th .strong {
font-weight: bold;
}
hr {
border: 0;
height: 0;
border-top: 1px solid black;
}
.list-view .highlight {
text-align: left;
border: 0px;
width: 20%;
padding-right: 15px;
padding-left: 20px;
font-weight: bold;
}
.tabular-view .odd-row {
background-color: #f9f9f9;
}
.section {
font-weight: bold;
padding-top:25px;
}
body {
margin-left: 50px;
}
.group {
margin-bottom: 30px;
}
.function {
margin-left: 20px;
}
</style>
<h1>Expressions documentation single page (locale en)</h1>
<a href="#aggregates"><h2 id="aggregates-idx">Aggregates</h2></a><ul><li><a href="#aggregates-aggregate"><span id="aggregates-aggregate-idx">aggregate</span></a></li><li><a href="#aggregates-array_agg"><span id="aggregates-array_agg-idx">array_agg</span></a></li><li><a href="#aggregates-collect"><span id="aggregates-collect-idx">collect</span></a></li><li><a href="#aggregates-concatenate"><span id="aggregates-concatenate-idx">concatenate</span></a></li><li><a href="#aggregates-concatenate_unique"><span id="aggregates-concatenate_unique-idx">concatenate_unique</span></a></li><li><a href="#aggregates-count"><span id="aggregates-count-idx">count</span></a></li><li><a href="#aggregates-count_distinct"><span id="aggregates-count_distinct-idx">count_distinct</span></a></li><li><a href="#aggregates-count_missing"><span id="aggregates-count_missing-idx">count_missing</span></a></li><li><a href="#aggregates-iqr"><span id="aggregates-iqr-idx">iqr</span></a></li><li><a href="#aggregates-majority"><span id="aggregates-majority-idx">majority</span></a></li><li><a href="#aggregates-max_length"><span id="aggregates-max_length-idx">max_length</span></a></li><li><a href="#aggregates-maximum"><span id="aggregates-maximum-idx">maximum</span></a></li><li><a href="#aggregates-mean"><span id="aggregates-mean-idx">mean</span></a></li><li><a href="#aggregates-median"><span id="aggregates-median-idx">median</span></a></li><li><a href="#aggregates-min_length"><span id="aggregates-min_length-idx">min_length</span></a></li><li><a href="#aggregates-minimum"><span id="aggregates-minimum-idx">minimum</span></a></li><li><a href="#aggregates-minority"><span id="aggregates-minority-idx">minority</span></a></li><li><a href="#aggregates-q1"><span id="aggregates-q1-idx">q1</span></a></li><li><a href="#aggregates-q3"><span id="aggregates-q3-idx">q3</span></a></li><li><a href="#aggregates-range"><span id="aggregates-range-idx">range</span></a></li><li><a href="#aggregates-relation_aggregate"><span id="aggregates-relation_aggregate-idx">relation_aggregate</span></a></li><li><a href="#aggregates-stdev"><span id="aggregates-stdev-idx">stdev</span></a></li><li><a href="#aggregates-sum"><span id="aggregates-sum-idx">sum</span></a></li></ul><a href="#arrays"><h2 id="arrays-idx">Arrays</h2></a><ul><li><a href="#arrays-array"><span id="arrays-array-idx">array</span></a></li><li><a href="#arrays-array_all"><span id="arrays-array_all-idx">array_all</span></a></li><li><a href="#arrays-array_append"><span id="arrays-array_append-idx">array_append</span></a></li><li><a href="#arrays-array_cat"><span id="arrays-array_cat-idx">array_cat</span></a></li><li><a href="#arrays-array_contains"><span id="arrays-array_contains-idx">array_contains</span></a></li><li><a href="#arrays-array_distinct"><span id="arrays-array_distinct-idx">array_distinct</span></a></li><li><a href="#arrays-array_filter"><span id="arrays-array_filter-idx">array_filter</span></a></li><li><a href="#arrays-array_find"><span id="arrays-array_find-idx">array_find</span></a></li><li><a href="#arrays-array_first"><span id="arrays-array_first-idx">array_first</span></a></li><li><a href="#arrays-array_foreach"><span id="arrays-array_foreach-idx">array_foreach</span></a></li><li><a href="#arrays-array_get"><span id="arrays-array_get-idx">array_get</span></a></li><li><a href="#arrays-array_insert"><span id="arrays-array_insert-idx">array_insert</span></a></li><li><a href="#arrays-array_intersect"><span id="arrays-array_intersect-idx">array_intersect</span></a></li><li><a href="#arrays-array_last"><span id="arrays-array_last-idx">array_last</span></a></li><li><a href="#arrays-array_length"><span id="arrays-array_length-idx">array_length</span></a></li><li><a href="#arrays-array_prepend"><span id="arrays-array_prepend-idx">array_prepend</span></a></li><li><a href="#arrays-array_remove_all"><span id="arrays-array_remove_all-idx">array_remove_all</span></a></li><li><a href="#arrays-array_remove_at"><span id="arrays-array_remove_at-idx">array_remove_at</span></a></li><li><a href="#arrays-array_reverse"><span id="arrays-array_reverse-idx">array_reverse</span></a></li><li><a href="#arrays-array_slice"><span id="arrays-array_slice-idx">array_slice</span></a></li><li><a href="#arrays-array_sort"><span id="arrays-array_sort-idx">array_sort</span></a></li><li><a href="#arrays-array_to_string"><span id="arrays-array_to_string-idx">array_to_string</span></a></li><li><a href="#arrays-generate_series"><span id="arrays-generate_series-idx">generate_series</span></a></li><li><a href="#arrays-regexp_matches"><span id="arrays-regexp_matches-idx">regexp_matches</span></a></li><li><a href="#arrays-string_to_array"><span id="arrays-string_to_array-idx">string_to_array</span></a></li></ul><a href="#color"><h2 id="color-idx">Color</h2></a><ul><li><a href="#color-color_cmyk"><span id="color-color_cmyk-idx">color_cmyk</span></a></li><li><a href="#color-color_cmyka"><span id="color-color_cmyka-idx">color_cmyka</span></a></li><li><a href="#color-color_grayscale_average"><span id="color-color_grayscale_average-idx">color_grayscale_average</span></a></li><li><a href="#color-color_hsl"><span id="color-color_hsl-idx">color_hsl</span></a></li><li><a href="#color-color_hsla"><span id="color-color_hsla-idx">color_hsla</span></a></li><li><a href="#color-color_hsv"><span id="color-color_hsv-idx">color_hsv</span></a></li><li><a href="#color-color_hsva"><span id="color-color_hsva-idx">color_hsva</span></a></li><li><a href="#color-color_mix_rgb"><span id="color-color_mix_rgb-idx">color_mix_rgb</span></a></li><li><a href="#color-color_part"><span id="color-color_part-idx">color_part</span></a></li><li><a href="#color-color_rgb"><span id="color-color_rgb-idx">color_rgb</span></a></li><li><a href="#color-color_rgba"><span id="color-color_rgba-idx">color_rgba</span></a></li><li><a href="#color-create_ramp"><span id="color-create_ramp-idx">create_ramp</span></a></li><li><a href="#color-darker"><span id="color-darker-idx">darker</span></a></li><li><a href="#color-lighter"><span id="color-lighter-idx">lighter</span></a></li><li><a href="#color-project_color"><span id="color-project_color-idx">project_color</span></a></li><li><a href="#color-ramp_color"><span id="color-ramp_color-idx">ramp_color</span></a></li><li><a href="#color-set_color_part"><span id="color-set_color_part-idx">set_color_part</span></a></li></ul><a href="#conditionals"><h2 id="conditionals-idx">Conditionals</h2></a><ul><li><a href="#conditionals-coalesce"><span id="conditionals-coalesce-idx">coalesce</span></a></li><li><a href="#conditionals-if"><span id="conditionals-if-idx">if</span></a></li><li><a href="#conditionals-nullif"><span id="conditionals-nullif-idx">nullif</span></a></li><li><a href="#conditionals-regexp_match"><span id="conditionals-regexp_match-idx">regexp_match</span></a></li><li><a href="#conditionals-try"><span id="conditionals-try-idx">try</span></a></li></ul><a href="#conversions"><h2 id="conversions-idx">Conversions</h2></a><ul><li><a href="#conversions-hash"><span id="conversions-hash-idx">hash</span></a></li><li><a href="#conversions-md5"><span id="conversions-md5-idx">md5</span></a></li><li><a href="#conversions-sha256"><span id="conversions-sha256-idx">sha256</span></a></li><li><a href="#conversions-to_date"><span id="conversions-to_date-idx">to_date</span></a></li><li><a href="#conversions-to_datetime"><span id="conversions-to_datetime-idx">to_datetime</span></a></li><li><a href="#conversions-to_dm"><span id="conversions-to_dm-idx">to_dm</span></a></li><li><a href="#conversions-to_dms"><span id="conversions-to_dms-idx">to_dms</span></a></li><li><a href="#conversions-to_int"><span id="conversions-to_int-idx">to_int</span></a></li><li><a href="#conversions-to_interval"><span id="conversions-to_interval-idx">to_interval</span></a></li><li><a href="#conversions-to_real"><span id="conversions-to_real-idx">to_real</span></a></li><li><a href="#conversions-to_string"><span id="conversions-to_string-idx">to_string</span></a></li><li><a href="#conversions-to_time"><span id="conversions-to_time-idx">to_time</span></a></li></ul><a href="#date-and-time"><h2 id="date-and-time-idx">Date and Time</h2></a><ul><li><a href="#date-and-time-age"><span id="date-and-time-age-idx">age</span></a></li><li><a href="#date-and-time-datetime_from_epoch"><span id="date-and-time-datetime_from_epoch-idx">datetime_from_epoch</span></a></li><li><a href="#date-and-time-day"><span id="date-and-time-day-idx">day</span></a></li><li><a href="#date-and-time-day_of_week"><span id="date-and-time-day_of_week-idx">day_of_week</span></a></li><li><a href="#date-and-time-epoch"><span id="date-and-time-epoch-idx">epoch</span></a></li><li><a href="#date-and-time-format_date"><span id="date-and-time-format_date-idx">format_date</span></a></li><li><a href="#date-and-time-hour"><span id="date-and-time-hour-idx">hour</span></a></li><li><a href="#date-and-time-minute"><span id="date-and-time-minute-idx">minute</span></a></li><li><a href="#date-and-time-month"><span id="date-and-time-month-idx">month</span></a></li><li><a href="#date-and-time-now"><span id="date-and-time-now-idx">now</span></a></li><li><a href="#date-and-time-second"><span id="date-and-time-second-idx">second</span></a></li><li><a href="#date-and-time-to_date"><span id="date-and-time-to_date-idx">to_date</span></a></li><li><a href="#date-and-time-to_datetime"><span id="date-and-time-to_datetime-idx">to_datetime</span></a></li><li><a href="#date-and-time-to_interval"><span id="date-and-time-to_interval-idx">to_interval</span></a></li><li><a href="#date-and-time-to_time"><span id="date-and-time-to_time-idx">to_time</span></a></li><li><a href="#date-and-time-week"><span id="date-and-time-week-idx">week</span></a></li><li><a href="#date-and-time-year"><span id="date-and-time-year-idx">year</span></a></li></ul><a href="#files-and-paths"><h2 id="files-and-paths-idx">Files and Paths</h2></a><ul><li><a href="#files-and-paths-base_file_name"><span id="files-and-paths-base_file_name-idx">base_file_name</span></a></li><li><a href="#files-and-paths-file_exists"><span id="files-and-paths-file_exists-idx">file_exists</span></a></li><li><a href="#files-and-paths-file_name"><span id="files-and-paths-file_name-idx">file_name</span></a></li><li><a href="#files-and-paths-file_path"><span id="files-and-paths-file_path-idx">file_path</span></a></li><li><a href="#files-and-paths-file_size"><span id="files-and-paths-file_size-idx">file_size</span></a></li><li><a href="#files-and-paths-file_suffix"><span id="files-and-paths-file_suffix-idx">file_suffix</span></a></li><li><a href="#files-and-paths-is_directory"><span id="files-and-paths-is_directory-idx">is_directory</span></a></li><li><a href="#files-and-paths-is_file"><span id="files-and-paths-is_file-idx">is_file</span></a></li></ul><a href="#form"><h2 id="form-idx">Form</h2></a><ul><li><a href="#form-current_value"><span id="form-current_value-idx">current_value</span></a></li></ul><a href="#fuzzy-matching"><h2 id="fuzzy-matching-idx">Fuzzy Matching</h2></a><ul><li><a href="#fuzzy-matching-hamming_distance"><span id="fuzzy-matching-hamming_distance-idx">hamming_distance</span></a></li><li><a href="#fuzzy-matching-levenshtein"><span id="fuzzy-matching-levenshtein-idx">levenshtein</span></a></li><li><a href="#fuzzy-matching-longest_common_substring"><span id="fuzzy-matching-longest_common_substring-idx">longest_common_substring</span></a></li><li><a href="#fuzzy-matching-soundex"><span id="fuzzy-matching-soundex-idx">soundex</span></a></li></ul><a href="#general"><h2 id="general-idx">General</h2></a><ul><li><a href="#general-env"><span id="general-env-idx">env</span></a></li><li><a href="#general-eval"><span id="general-eval-idx">eval</span></a></li><li><a href="#general-is_layer_visible"><span id="general-is_layer_visible-idx">is_layer_visible</span></a></li><li><a href="#general-layer_property"><span id="general-layer_property-idx">layer_property</span></a></li><li><a href="#general-var"><span id="general-var-idx">var</span></a></li><li><a href="#general-with_variable"><span id="general-with_variable-idx">with_variable</span></a></li></ul><a href="#geometrygroup"><h2 id="geometrygroup-idx">Geometry</h2></a><ul><li><a href="#geometrygroup-dollar-area"><span id="geometrygroup-dollar-area-idx">$area</span></a></li><li><a href="#geometrygroup-dollar-geometry"><span id="geometrygroup-dollar-geometry-idx">$geometry</span></a></li><li><a href="#geometrygroup-dollar-length"><span id="geometrygroup-dollar-length-idx">$length</span></a></li><li><a href="#geometrygroup-dollar-perimeter"><span id="geometrygroup-dollar-perimeter-idx">$perimeter</span></a></li><li><a href="#geometrygroup-dollar-x"><span id="geometrygroup-dollar-x-idx">$x</span></a></li><li><a href="#geometrygroup-dollar-x_at"><span id="geometrygroup-dollar-x_at-idx">$x_at</span></a></li><li><a href="#geometrygroup-dollar-y"><span id="geometrygroup-dollar-y-idx">$y</span></a></li><li><a href="#geometrygroup-dollar-y_at"><span id="geometrygroup-dollar-y_at-idx">$y_at</span></a></li><li><a href="#geometrygroup-angle_at_vertex"><span id="geometrygroup-angle_at_vertex-idx">angle_at_vertex</span></a></li><li><a href="#geometrygroup-area"><span id="geometrygroup-area-idx">area</span></a></li><li><a href="#geometrygroup-azimuth"><span id="geometrygroup-azimuth-idx">azimuth</span></a></li><li><a href="#geometrygroup-boundary"><span id="geometrygroup-boundary-idx">boundary</span></a></li><li><a href="#geometrygroup-bounds"><span id="geometrygroup-bounds-idx">bounds</span></a></li><li><a href="#geometrygroup-bounds_height"><span id="geometrygroup-bounds_height-idx">bounds_height</span></a></li><li><a href="#geometrygroup-bounds_width"><span id="geometrygroup-bounds_width-idx">bounds_width</span></a></li><li><a href="#geometrygroup-buffer"><span id="geometrygroup-buffer-idx">buffer</span></a></li><li><a href="#geometrygroup-buffer_by_m"><span id="geometrygroup-buffer_by_m-idx">buffer_by_m</span></a></li><li><a href="#geometrygroup-centroid"><span id="geometrygroup-centroid-idx">centroid</span></a></li><li><a href="#geometrygroup-closest_point"><span id="geometrygroup-closest_point-idx">closest_point</span></a></li><li><a href="#geometrygroup-collect_geometries"><span id="geometrygroup-collect_geometries-idx">collect_geometries</span></a></li><li><a href="#geometrygroup-combine"><span id="geometrygroup-combine-idx">combine</span></a></li><li><a href="#geometrygroup-contains"><span id="geometrygroup-contains-idx">contains</span></a></li><li><a href="#geometrygroup-convex_hull"><span id="geometrygroup-convex_hull-idx">convex_hull</span></a></li><li><a href="#geometrygroup-crosses"><span id="geometrygroup-crosses-idx">crosses</span></a></li><li><a href="#geometrygroup-difference"><span id="geometrygroup-difference-idx">difference</span></a></li><li><a href="#geometrygroup-disjoint"><span id="geometrygroup-disjoint-idx">disjoint</span></a></li><li><a href="#geometrygroup-distance"><span id="geometrygroup-distance-idx">distance</span></a></li><li><a href="#geometrygroup-distance_to_vertex"><span id="geometrygroup-distance_to_vertex-idx">distance_to_vertex</span></a></li><li><a href="#geometrygroup-end_point"><span id="geometrygroup-end_point-idx">end_point</span></a></li><li><a href="#geometrygroup-extend"><span id="geometrygroup-extend-idx">extend</span></a></li><li><a href="#geometrygroup-exterior_ring"><span id="geometrygroup-exterior_ring-idx">exterior_ring</span></a></li><li><a href="#geometrygroup-extrude"><span id="geometrygroup-extrude-idx">extrude</span></a></li><li><a href="#geometrygroup-flip_coordinates"><span id="geometrygroup-flip_coordinates-idx">flip_coordinates</span></a></li><li><a href="#geometrygroup-force_rhr"><span id="geometrygroup-force_rhr-idx">force_rhr</span></a></li><li><a href="#geometrygroup-geom_from_gml"><span id="geometrygroup-geom_from_gml-idx">geom_from_gml</span></a></li><li><a href="#geometrygroup-geom_from_wkb"><span id="geometrygroup-geom_from_wkb-idx">geom_from_wkb</span></a></li><li><a href="#geometrygroup-geom_from_wkt"><span id="geometrygroup-geom_from_wkt-idx">geom_from_wkt</span></a></li><li><a href="#geometrygroup-geom_to_wkb"><span id="geometrygroup-geom_to_wkb-idx">geom_to_wkb</span></a></li><li><a href="#geometrygroup-geom_to_wkt"><span id="geometrygroup-geom_to_wkt-idx">geom_to_wkt</span></a></li><li><a href="#geometrygroup-geometry"><span id="geometrygroup-geometry-idx">geometry</span></a></li><li><a href="#geometrygroup-geometry_n"><span id="geometrygroup-geometry_n-idx">geometry_n</span></a></li><li><a href="#geometrygroup-hausdorff_distance"><span id="geometrygroup-hausdorff_distance-idx">hausdorff_distance</span></a></li><li><a href="#geometrygroup-inclination"><span id="geometrygroup-inclination-idx">inclination</span></a></li><li><a href="#geometrygroup-interior_ring_n"><span id="geometrygroup-interior_ring_n-idx">interior_ring_n</span></a></li><li><a href="#geometrygroup-intersection"><span id="geometrygroup-intersection-idx">intersection</span></a></li><li><a href="#geometrygroup-intersects"><span id="geometrygroup-intersects-idx">intersects</span></a></li><li><a href="#geometrygroup-intersects_bbox"><span id="geometrygroup-intersects_bbox-idx">intersects_bbox</span></a></li><li><a href="#geometrygroup-is_closed"><span id="geometrygroup-is_closed-idx">is_closed</span></a></li><li><a href="#geometrygroup-is_empty"><span id="geometrygroup-is_empty-idx">is_empty</span></a></li><li><a href="#geometrygroup-is_empty_or_null"><span id="geometrygroup-is_empty_or_null-idx">is_empty_or_null</span></a></li><li><a href="#geometrygroup-is_valid"><span id="geometrygroup-is_valid-idx">is_valid</span></a></li><li><a href="#geometrygroup-length"><span id="geometrygroup-length-idx">length</span></a></li><li><a href="#geometrygroup-line_interpolate_angle"><span id="geometrygroup-line_interpolate_angle-idx">line_interpolate_angle</span></a></li><li><a href="#geometrygroup-line_interpolate_point"><span id="geometrygroup-line_interpolate_point-idx">line_interpolate_point</span></a></li><li><a href="#geometrygroup-line_locate_point"><span id="geometrygroup-line_locate_point-idx">line_locate_point</span></a></li><li><a href="#geometrygroup-line_merge"><span id="geometrygroup-line_merge-idx">line_merge</span></a></li><li><a href="#geometrygroup-line_substring"><span id="geometrygroup-line_substring-idx">line_substring</span></a></li><li><a href="#geometrygroup-m"><span id="geometrygroup-m-idx">m</span></a></li><li><a href="#geometrygroup-make_circle"><span id="geometrygroup-make_circle-idx">make_circle</span></a></li><li><a href="#geometrygroup-make_ellipse"><span id="geometrygroup-make_ellipse-idx">make_ellipse</span></a></li><li><a href="#geometrygroup-make_line"><span id="geometrygroup-make_line-idx">make_line</span></a></li><li><a href="#geometrygroup-make_point"><span id="geometrygroup-make_point-idx">make_point</span></a></li><li><a href="#geometrygroup-make_point_m"><span id="geometrygroup-make_point_m-idx">make_point_m</span></a></li><li><a href="#geometrygroup-make_polygon"><span id="geometrygroup-make_polygon-idx">make_polygon</span></a></li><li><a href="#geometrygroup-make_rectangle_3points"><span id="geometrygroup-make_rectangle_3points-idx">make_rectangle_3points</span></a></li><li><a href="#geometrygroup-make_regular_polygon"><span id="geometrygroup-make_regular_polygon-idx">make_regular_polygon</span></a></li><li><a href="#geometrygroup-make_square"><span id="geometrygroup-make_square-idx">make_square</span></a></li><li><a href="#geometrygroup-make_triangle"><span id="geometrygroup-make_triangle-idx">make_triangle</span></a></li><li><a href="#geometrygroup-minimal_circle"><span id="geometrygroup-minimal_circle-idx">minimal_circle</span></a></li><li><a href="#geometrygroup-nodes_to_points"><span id="geometrygroup-nodes_to_points-idx">nodes_to_points</span></a></li><li><a href="#geometrygroup-num_geometries"><span id="geometrygroup-num_geometries-idx">num_geometries</span></a></li><li><a href="#geometrygroup-num_interior_rings"><span id="geometrygroup-num_interior_rings-idx">num_interior_rings</span></a></li><li><a href="#geometrygroup-num_points"><span id="geometrygroup-num_points-idx">num_points</span></a></li><li><a href="#geometrygroup-num_rings"><span id="geometrygroup-num_rings-idx">num_rings</span></a></li><li><a href="#geometrygroup-offset_curve"><span id="geometrygroup-offset_curve-idx">offset_curve</span></a></li><li><a href="#geometrygroup-order_parts"><span id="geometrygroup-order_parts-idx">order_parts</span></a></li><li><a href="#geometrygroup-oriented_bbox"><span id="geometrygroup-oriented_bbox-idx">oriented_bbox</span></a></li><li><a href="#geometrygroup-overlaps"><span id="geometrygroup-overlaps-idx">overlaps</span></a></li><li><a href="#geometrygroup-perimeter"><span id="geometrygroup-perimeter-idx">perimeter</span></a></li><li><a href="#geometrygroup-point_n"><span id="geometrygroup-point_n-idx">point_n</span></a></li><li><a href="#geometrygroup-point_on_surface"><span id="geometrygroup-point_on_surface-idx">point_on_surface</span></a></li><li><a href="#geometrygroup-pole_of_inaccessibility"><span id="geometrygroup-pole_of_inaccessibility-idx">pole_of_inaccessibility</span></a></li><li><a href="#geometrygroup-project"><span id="geometrygroup-project-idx">project</span></a></li><li><a href="#geometrygroup-relate"><span id="geometrygroup-relate-idx">relate</span></a></li><li><a href="#geometrygroup-reverse"><span id="geometrygroup-reverse-idx">reverse</span></a></li><li><a href="#geometrygroup-rotate"><span id="geometrygroup-rotate-idx">rotate</span></a></li><li><a href="#geometrygroup-segments_to_lines"><span id="geometrygroup-segments_to_lines-idx">segments_to_lines</span></a></li><li><a href="#geometrygroup-shortest_line"><span id="geometrygroup-shortest_line-idx">shortest_line</span></a></li><li><a href="#geometrygroup-simplify"><span id="geometrygroup-simplify-idx">simplify</span></a></li><li><a href="#geometrygroup-simplify_vw"><span id="geometrygroup-simplify_vw-idx">simplify_vw</span></a></li><li><a href="#geometrygroup-single_sided_buffer"><span id="geometrygroup-single_sided_buffer-idx">single_sided_buffer</span></a></li><li><a href="#geometrygroup-smooth"><span id="geometrygroup-smooth-idx">smooth</span></a></li><li><a href="#geometrygroup-start_point"><span id="geometrygroup-start_point-idx">start_point</span></a></li><li><a href="#geometrygroup-sym_difference"><span id="geometrygroup-sym_difference-idx">sym_difference</span></a></li><li><a href="#geometrygroup-tapered_buffer"><span id="geometrygroup-tapered_buffer-idx">tapered_buffer</span></a></li><li><a href="#geometrygroup-touches"><span id="geometrygroup-touches-idx">touches</span></a></li><li><a href="#geometrygroup-transform"><span id="geometrygroup-transform-idx">transform</span></a></li><li><a href="#geometrygroup-translate"><span id="geometrygroup-translate-idx">translate</span></a></li><li><a href="#geometrygroup-union"><span id="geometrygroup-union-idx">union</span></a></li><li><a href="#geometrygroup-wedge_buffer"><span id="geometrygroup-wedge_buffer-idx">wedge_buffer</span></a></li><li><a href="#geometrygroup-within"><span id="geometrygroup-within-idx">within</span></a></li><li><a href="#geometrygroup-x"><span id="geometrygroup-x-idx">x</span></a></li><li><a href="#geometrygroup-x_max"><span id="geometrygroup-x_max-idx">x_max</span></a></li><li><a href="#geometrygroup-x_min"><span id="geometrygroup-x_min-idx">x_min</span></a></li><li><a href="#geometrygroup-y"><span id="geometrygroup-y-idx">y</span></a></li><li><a href="#geometrygroup-y_max"><span id="geometrygroup-y_max-idx">y_max</span></a></li><li><a href="#geometrygroup-y_min"><span id="geometrygroup-y_min-idx">y_min</span></a></li><li><a href="#geometrygroup-z"><span id="geometrygroup-z-idx">z</span></a></li></ul><a href="#layout"><h2 id="layout-idx">Layout</h2></a><ul><li><a href="#layout-item_variables"><span id="layout-item_variables-idx">item_variables</span></a></li></ul><a href="#map-layers"><h2 id="map-layers-idx">Map Layers</h2></a><ul><li><a href="#map-layers-decode_uri"><span id="map-layers-decode_uri-idx">decode_uri</span></a></li></ul><a href="#maps"><h2 id="maps-idx">Maps</h2></a><ul><li><a href="#maps-from_json"><span id="maps-from_json-idx">from_json</span></a></li><li><a href="#maps-hstore_to_map"><span id="maps-hstore_to_map-idx">hstore_to_map</span></a></li><li><a href="#maps-json_to_map"><span id="maps-json_to_map-idx">json_to_map</span></a></li><li><a href="#maps-map"><span id="maps-map-idx">map</span></a></li><li><a href="#maps-map_akeys"><span id="maps-map_akeys-idx">map_akeys</span></a></li><li><a href="#maps-map_avals"><span id="maps-map_avals-idx">map_avals</span></a></li><li><a href="#maps-map_concat"><span id="maps-map_concat-idx">map_concat</span></a></li><li><a href="#maps-map_delete"><span id="maps-map_delete-idx">map_delete</span></a></li><li><a href="#maps-map_exist"><span id="maps-map_exist-idx">map_exist</span></a></li><li><a href="#maps-map_get"><span id="maps-map_get-idx">map_get</span></a></li><li><a href="#maps-map_insert"><span id="maps-map_insert-idx">map_insert</span></a></li><li><a href="#maps-map_to_hstore"><span id="maps-map_to_hstore-idx">map_to_hstore</span></a></li><li><a href="#maps-map_to_json"><span id="maps-map_to_json-idx">map_to_json</span></a></li><li><a href="#maps-to_json"><span id="maps-to_json-idx">to_json</span></a></li></ul><a href="#math"><h2 id="math-idx">Math</h2></a><ul><li><a href="#math-abs"><span id="math-abs-idx">abs</span></a></li><li><a href="#math-acos"><span id="math-acos-idx">acos</span></a></li><li><a href="#math-asin"><span id="math-asin-idx">asin</span></a></li><li><a href="#math-atan"><span id="math-atan-idx">atan</span></a></li><li><a href="#math-atan2"><span id="math-atan2-idx">atan2</span></a></li><li><a href="#math-azimuth"><span id="math-azimuth-idx">azimuth</span></a></li><li><a href="#math-ceil"><span id="math-ceil-idx">ceil</span></a></li><li><a href="#math-clamp"><span id="math-clamp-idx">clamp</span></a></li><li><a href="#math-cos"><span id="math-cos-idx">cos</span></a></li><li><a href="#math-degrees"><span id="math-degrees-idx">degrees</span></a></li><li><a href="#math-exp"><span id="math-exp-idx">exp</span></a></li><li><a href="#math-floor"><span id="math-floor-idx">floor</span></a></li><li><a href="#math-inclination"><span id="math-inclination-idx">inclination</span></a></li><li><a href="#math-ln"><span id="math-ln-idx">ln</span></a></li><li><a href="#math-log"><span id="math-log-idx">log</span></a></li><li><a href="#math-log10"><span id="math-log10-idx">log10</span></a></li><li><a href="#math-max"><span id="math-max-idx">max</span></a></li><li><a href="#math-min"><span id="math-min-idx">min</span></a></li><li><a href="#math-pi"><span id="math-pi-idx">pi</span></a></li><li><a href="#math-radians"><span id="math-radians-idx">radians</span></a></li><li><a href="#math-rand"><span id="math-rand-idx">rand</span></a></li><li><a href="#math-randf"><span id="math-randf-idx">randf</span></a></li><li><a href="#math-round"><span id="math-round-idx">round</span></a></li><li><a href="#math-scale_exp"><span id="math-scale_exp-idx">scale_exp</span></a></li><li><a href="#math-scale_linear"><span id="math-scale_linear-idx">scale_linear</span></a></li><li><a href="#math-sin"><span id="math-sin-idx">sin</span></a></li><li><a href="#math-sqrt"><span id="math-sqrt-idx">sqrt</span></a></li><li><a href="#math-tan"><span id="math-tan-idx">tan</span></a></li></ul><a href="#processing"><h2 id="processing-idx">Processing</h2></a><ul><li><a href="#processing-parameter"><span id="processing-parameter-idx">parameter</span></a></li></ul><a href="#rasters"><h2 id="rasters-idx">Rasters</h2></a><ul><li><a href="#rasters-raster_statistic"><span id="rasters-raster_statistic-idx">raster_statistic</span></a></li><li><a href="#rasters-raster_value"><span id="rasters-raster_value-idx">raster_value</span></a></li></ul><a href="#record-and-attributes"><h2 id="record-and-attributes-idx">Record and Attributes</h2></a><ul><li><a href="#record-and-attributes-dollar-currentfeature"><span id="record-and-attributes-dollar-currentfeature-idx">$currentfeature</span></a></li><li><a href="#record-and-attributes-dollar-id"><span id="record-and-attributes-dollar-id-idx">$id</span></a></li><li><a href="#record-and-attributes-attribute"><span id="record-and-attributes-attribute-idx">attribute</span></a></li><li><a href="#record-and-attributes-attributes"><span id="record-and-attributes-attributes-idx">attributes</span></a></li><li><a href="#record-and-attributes-get_feature"><span id="record-and-attributes-get_feature-idx">get_feature</span></a></li><li><a href="#record-and-attributes-get_feature_by_id"><span id="record-and-attributes-get_feature_by_id-idx">get_feature_by_id</span></a></li><li><a href="#record-and-attributes-is_selected"><span id="record-and-attributes-is_selected-idx">is_selected</span></a></li><li><a href="#record-and-attributes-num_selected"><span id="record-and-attributes-num_selected-idx">num_selected</span></a></li><li><a href="#record-and-attributes-represent_value"><span id="record-and-attributes-represent_value-idx">represent_value</span></a></li><li><a href="#record-and-attributes-sqlite_fetch_and_increment"><span id="record-and-attributes-sqlite_fetch_and_increment-idx">sqlite_fetch_and_increment</span></a></li><li><a href="#record-and-attributes-uuid"><span id="record-and-attributes-uuid-idx">uuid</span></a></li></ul><a href="#string"><h2 id="string-idx">String</h2></a><ul><li><a href="#string-char"><span id="string-char-idx">char</span></a></li><li><a href="#string-concat"><span id="string-concat-idx">concat</span></a></li><li><a href="#string-format"><span id="string-format-idx">format</span></a></li><li><a href="#string-format_date"><span id="string-format_date-idx">format_date</span></a></li><li><a href="#string-format_number"><span id="string-format_number-idx">format_number</span></a></li><li><a href="#string-left"><span id="string-left-idx">left</span></a></li><li><a href="#string-length"><span id="string-length-idx">length</span></a></li><li><a href="#string-lower"><span id="string-lower-idx">lower</span></a></li><li><a href="#string-lpad"><span id="string-lpad-idx">lpad</span></a></li><li><a href="#string-regexp_match"><span id="string-regexp_match-idx">regexp_match</span></a></li><li><a href="#string-regexp_replace"><span id="string-regexp_replace-idx">regexp_replace</span></a></li><li><a href="#string-regexp_substr"><span id="string-regexp_substr-idx">regexp_substr</span></a></li><li><a href="#string-replace"><span id="string-replace-idx">replace</span></a></li><li><a href="#string-right"><span id="string-right-idx">right</span></a></li><li><a href="#string-rpad"><span id="string-rpad-idx">rpad</span></a></li><li><a href="#string-strpos"><span id="string-strpos-idx">strpos</span></a></li><li><a href="#string-substr"><span id="string-substr-idx">substr</span></a></li><li><a href="#string-title"><span id="string-title-idx">title</span></a></li><li><a href="#string-to_string"><span id="string-to_string-idx">to_string</span></a></li><li><a href="#string-trim"><span id="string-trim-idx">trim</span></a></li><li><a href="#string-upper"><span id="string-upper-idx">upper</span></a></li><li><a href="#string-wordwrap"><span id="string-wordwrap-idx">wordwrap</span></a></li></ul>
<div id="aggregates" class="group"><h2><a href="#aggregates-idx">group aggregates</a></h2>
<div class="description"><p>Contains functions which aggregate values over layers and fields.</p></div></div>
<div class="function"><h3 id="aggregates-aggregate"><a href="#aggregates-aggregate-idx">
function aggregate
</a></h3>
<div class="description">
<p>
Returns an aggregate value calculated using features from another layer.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
aggregate
</span>
(
<span class="argument">
layer
</span>
,
<span class="argument">
aggregate
</span>
,
<span class="argument">
expression
</span>
[,
<span class="argument">
filter
</span>
][,
<span class="argument">
concatenator
</span>
][,
<span class="argument">
order_by
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
layer
</td>
<td>
a string, representing either a layer name or layer ID
</td>
</tr>
<tr>
<td class="argument">
aggregate
</td>
<td>
a string corresponding to the aggregate to calculate. Valid options are:
<br/>
<ul>
<li>
count
</li>
<li>
count_distinct
</li>
<li>
count_missing
</li>
<li>
min
</li>
<li>
max
</li>
<li>
sum
</li>
<li>
mean
</li>
<li>
median
</li>
<li>
stdev
</li>
<li>
stdevsample
</li>
<li>
range
</li>
<li>
minority
</li>
<li>
majority
</li>
<li>
q1: first quartile
</li>
<li>
q3: third quartile
</li>
<li>
iqr: inter quartile range
</li>
<li>
min_length: minimum string length
</li>
<li>
max_length: maximum string length
</li>
<li>
concatenate: join strings with a concatenator
</li>
<li>
concatenate_unique: join unique strings with a concatenator
</li>
<li>
collect: create an aggregated multipart geometry
</li>
<li>
array_agg: create an array of aggregated values
</li>
</ul>
</td>
</tr>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression or field name to aggregate
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional filter expression to limit the features used for calculating the aggregate. Fields and geometry are from the features on the joined layer. The source feature can be accessed with the variable @parent.
</td>
</tr>
<tr>
<td class="argument">
concatenator
</td>
<td>
optional string to use to join values for 'concatenate' aggregate
</td>
</tr>
<tr>
<td class="argument">
order_by
</td>
<td>
optional filter expression to order the features used for calculating the aggregate. Fields and geometry are from the features on the joined layer.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
aggregate(layer:='rail_stations',aggregate:='sum',expression:="passengers")
</code>
→
<code>
sum of all values from the passengers field in the rail_stations layer
</code>
</li>
<li>
<code>
aggregate('rail_stations','sum', "passengers"/7)
</code>
→
<code>
calculates a daily average of "passengers" by dividing the "passengers" field by 7 before summing the values
</code>
</li>
<li>
<code>
aggregate(layer:='rail_stations',aggregate:='sum',expression:="passengers",filter:="class"&gt;3)
</code>
→
<code>
sums up all values from the "passengers" field from features where the "class" attribute is greater than 3 only
</code>
</li>
<li>
<code>
aggregate(layer:='rail_stations',aggregate:='concatenate', expression:="name", concatenator:=',')
</code>
→
<code>
comma separated list of the name field for all features in the rail_stations layer
</code>
</li>
<li>
<code>
aggregate(layer:='countries', aggregate:='max', expression:="code", filter:=intersects( $geometry, geometry(@parent) ) )
</code>
→
<code>
The country code of an intersecting country on the layer 'countries'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-array_agg"><a href="#aggregates-array_agg-idx">
function array_agg
</a></h3>
<div class="description">
<p>
Returns an array of aggregated values from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_agg
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
][,
<span class="argument">
order_by
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
<tr>
<td class="argument">
order_by
</td>
<td>
optional expression to use to order features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_agg("name",group_by:="state")
</code>
→
<code>
list of name values, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-collect"><a href="#aggregates-collect-idx">
function collect
</a></h3>
<div class="description">
<p>
Returns the multipart geometry of aggregated geometries from an expression
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
collect
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
geometry expression to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
collect( $geometry )
</code>
→
<code>
multipart geometry of aggregated geometries
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-concatenate"><a href="#aggregates-concatenate-idx">
function concatenate
</a></h3>
<div class="description">
<p>
Returns all aggregated strings from a field or expression joined by a delimiter.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
concatenate
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
][,
<span class="argument">
concatenator
</span>
][,
<span class="argument">
order_by
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
<tr>
<td class="argument">
concatenator
</td>
<td>
optional string to use to join values
</td>
</tr>
<tr>
<td class="argument">
order_by
</td>
<td>
optional expression to use to order features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
concatenate("town_name",group_by:="state",concatenator:=',')
</code>
→
<code>
comma separated list of town_names, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-concatenate_unique"><a href="#aggregates-concatenate_unique-idx">
function concatenate_unique
</a></h3>
<div class="description">
<p>
Returns all unique strings from a field or expression joined by a delimiter.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
concatenate_unique
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
][,
<span class="argument">
concatenator
</span>
][,
<span class="argument">
order_by
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
<tr>
<td class="argument">
concatenator
</td>
<td>
optional string to use to join values
</td>
</tr>
<tr>
<td class="argument">
order_by
</td>
<td>
optional expression to use to order features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
concatenate("town_name",group_by:="state",concatenator:=',')
</code>
→
<code>
comma separated list of unique town_names, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-count"><a href="#aggregates-count-idx">
function count
</a></h3>
<div class="description">
<p>
Returns the count of matching features.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
count
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
count("stations",group_by:="state")
</code>
→
<code>
count of stations, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-count_distinct"><a href="#aggregates-count_distinct-idx">
function count_distinct
</a></h3>
<div class="description">
<p>
Returns the count of distinct values.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
count_distinct
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
count_distinct("stations",group_by:="state")
</code>
→
<code>
count of distinct stations values, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-count_missing"><a href="#aggregates-count_missing-idx">
function count_missing
</a></h3>
<div class="description">
<p>
Returns the count of missing (null) values.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
count_missing
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
count_missing("stations",group_by:="state")
</code>
→
<code>
count of missing (null) station values, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-iqr"><a href="#aggregates-iqr-idx">
function iqr
</a></h3>
<div class="description">
<p>
Returns the calculated inter quartile range from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
iqr
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
iqr("population",group_by:="state")
</code>
→
<code>
inter quartile range of population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-majority"><a href="#aggregates-majority-idx">
function majority
</a></h3>
<div class="description">
<p>
Returns the aggregate majority of values (most commonly occurring value) from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
majority
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
majority("class",group_by:="state")
</code>
→
<code>
most commonly occurring class value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-max_length"><a href="#aggregates-max_length-idx">
function max_length
</a></h3>
<div class="description">
<p>
Returns the maximum length of strings from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
max_length
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
max_length("town_name",group_by:="state")
</code>
→
<code>
maximum length of town_name, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-maximum"><a href="#aggregates-maximum-idx">
function maximum
</a></h3>
<div class="description">
<p>
Returns the aggregate maximum value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
maximum
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
maximum("population",group_by:="state")
</code>
→
<code>
maximum population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-mean"><a href="#aggregates-mean-idx">
function mean
</a></h3>
<div class="description">
<p>
Returns the aggregate mean value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
mean
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
mean("population",group_by:="state")
</code>
→
<code>
mean population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-median"><a href="#aggregates-median-idx">
function median
</a></h3>
<div class="description">
<p>
Returns the aggregate median value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
median
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
median("population",group_by:="state")
</code>
→
<code>
median population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-min_length"><a href="#aggregates-min_length-idx">
function min_length
</a></h3>
<div class="description">
<p>
Returns the minimum length of strings from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
min_length
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
min_length("town_name",group_by:="state")
</code>
→
<code>
minimum length of town_name, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-minimum"><a href="#aggregates-minimum-idx">
function minimum
</a></h3>
<div class="description">
<p>
Returns the aggregate minimum value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
minimum
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
minimum("population",group_by:="state")
</code>
→
<code>
minimum population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-minority"><a href="#aggregates-minority-idx">
function minority
</a></h3>
<div class="description">
<p>
Returns the aggregate minority of values (least occurring value) from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
minority
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
minority("class",group_by:="state")
</code>
→
<code>
least occurring class value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-q1"><a href="#aggregates-q1-idx">
function q1
</a></h3>
<div class="description">
<p>
Returns the calculated first quartile from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
q1
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
q1("population",group_by:="state")
</code>
→
<code>
first quartile of population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-q3"><a href="#aggregates-q3-idx">
function q3
</a></h3>
<div class="description">
<p>
Returns the calculated third quartile from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
q3
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
q3("population",group_by:="state")
</code>
→
<code>
third quartile of population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-range"><a href="#aggregates-range-idx">
function range
</a></h3>
<div class="description">
<p>
Returns the aggregate range of values (maximum - minimum) from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
range
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
range("population",group_by:="state")
</code>
→
<code>
range of population values, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-relation_aggregate"><a href="#aggregates-relation_aggregate-idx">
function relation_aggregate
</a></h3>
<div class="description">
<p>
Returns an aggregate value calculated using all matching child features from a layer relation.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
relation_aggregate
</span>
(
<span class="argument">
relation
</span>
,
<span class="argument">
aggregate
</span>
,
<span class="argument">
expression
</span>
[,
<span class="argument">
concatenator
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
relation
</td>
<td>
a string, representing a relation ID
</td>
</tr>
<tr>
<td class="argument">
aggregate
</td>
<td>
a string corresponding to the aggregate to calculate. Valid options are:
<br/>
<ul>
<li>
count
</li>
<li>
count_distinct
</li>
<li>
count_missing
</li>
<li>
min
</li>
<li>
max
</li>
<li>
sum
</li>
<li>
mean
</li>
<li>
median
</li>
<li>
stdev
</li>
<li>
stdevsample
</li>
<li>
range
</li>
<li>
minority
</li>
<li>
majority
</li>
<li>
q1: first quartile
</li>
<li>
q3: third quartile
</li>
<li>
iqr: inter quartile range
</li>
<li>
min_length: minimum string length
</li>
<li>
max_length: maximum string length
</li>
<li>
concatenate: join strings with a concatenator
</li>
<li>
concatenate_unique: join unique strings with a concatenator
</li>
<li>
collect: create an aggregated multipart geometry
</li>
<li>
array_agg: create an array of aggregated values
</li>
</ul>
</td>
</tr>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression or field name to aggregate
</td>
</tr>
<tr>
<td class="argument">
concatenator
</td>
<td>
optional string to use to join values for 'concatenate' aggregate
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional filter expression to order the features used for calculating the aggregate. Fields and geometry are from the features on the joined layer.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
relation_aggregate(relation:='my_relation',aggregate:='mean',expression:="passengers")
</code>
→
<code>
mean value of all matching child features using the 'my_relation' relation
</code>
</li>
<li>
<code>
relation_aggregate('my_relation','sum', "passengers"/7)
</code>
→
<code>
sum of the passengers field divided by 7 for all matching child features using the 'my_relation' relation
</code>
</li>
<li>
<code>
relation_aggregate('my_relation','concatenate', "towns", concatenator:=',')
</code>
→
<code>
comma separated list of the towns field for all matching child features using the 'my_relation' relation
</code>
</li>
<li>
<code>
relation_aggregate('my_relation','array_agg', "id")
</code>
→
<code>
array of the id field from all matching child features using the 'my_relation' relation
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-stdev"><a href="#aggregates-stdev-idx">
function stdev
</a></h3>
<div class="description">
<p>
Returns the aggregate standard deviation value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
stdev
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
stdev("population",group_by:="state")
</code>
→
<code>
standard deviation of population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="aggregates-sum"><a href="#aggregates-sum-idx">
function sum
</a></h3>
<div class="description">
<p>
Returns the aggregate summed value from a field or expression.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
sum
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
group_by
</span>
][,
<span class="argument">
filter
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
sub expression of field to aggregate
</td>
</tr>
<tr>
<td class="argument">
group_by
</td>
<td>
optional expression to use to group aggregate calculations
</td>
</tr>
<tr>
<td class="argument">
filter
</td>
<td>
optional expression to use to filter features used to calculate aggregate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
sum("population",group_by:="state")
</code>
→
<code>
summed population value, grouped by state field
</code>
</li>
</ul>
</div>
</div></div>
<div id="arrays" class="group"><h2><a href="#arrays-idx">group arrays</a></h2>
<div class="description"><p>This group contains expression functions for the creation and manipulation of arrays (also known as list data structures). The order of values within the array matters, in contrary to the 'map' data structure, where the order of key-value pairs is irrelevant and values are identified by their keys.</p></div></div>
<div class="function"><h3 id="arrays-array"><a href="#arrays-array-idx">
function array
</a></h3>
<div class="description">
<p>
Returns an array containing all the values passed as parameter.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array
</span>
(
<span class="argument">
value1
</span>
,
<span class="argument">
value2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
value
</td>
<td>
a value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array(2,10)
</code>
→
<code>
[ 2, 10 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_all"><a href="#arrays-array_all-idx">
function array_all
</a></h3>
<div class="description">
<p>
Returns true if an array contains all the values of a given array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_all
</span>
(
<span class="argument">
array_a
</span>
,
<span class="argument">
array_b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array_a
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
array_b
</td>
<td>
the array of values to search
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_all(array(1,2,3),array(2,3))
</code>
→
<code>
true
</code>
</li>
<li>
<code>
array_all(array(1,2,3),array(1,2,4))
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_append"><a href="#arrays-array_append-idx">
function array_append
</a></h3>
<div class="description">
<p>
Returns an array with the given value added at the end.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_append
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to add
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_append(array(1,2,3),4)
</code>
→
<code>
[ 1, 2, 3, 4 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_cat"><a href="#arrays-array_cat-idx">
function array_cat
</a></h3>
<div class="description">
<p>
Returns an array containing all the given arrays concatenated.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_cat
</span>
(
<span class="argument">
array1
</span>
,
<span class="argument">
array2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_cat(array(1,2),array(2,3))
</code>
→
<code>
[ 1, 2, 2, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_contains"><a href="#arrays-array_contains-idx">
function array_contains
</a></h3>
<div class="description">
<p>
Returns true if an array contains the given value.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_contains
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to search
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_contains(array(1,2,3),2)
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_distinct"><a href="#arrays-array_distinct-idx">
function array_distinct
</a></h3>
<div class="description">
<p>
Returns an array containing distinct values of the given array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_distinct
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_distinct(array(1,2,3,2,1))
</code>
→
<code>
[ 1, 2, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_filter"><a href="#arrays-array_filter-idx">
function array_filter
</a></h3>
<div class="description">
<p>
Returns an array with only the items for which the expression evaluates to true.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_filter
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
expression
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
expression
</td>
<td>
an expression to evaluate on each item. The variable `@element` will be replaced by the current value.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_filter(array(1,2,3),@element &lt; 3)
</code>
→
<code>
[ 1, 2 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_find"><a href="#arrays-array_find-idx">
function array_find
</a></h3>
<div class="description">
<p>
Returns the index (0 for the first one) of a value within an array. Returns -1 if the value is not found.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_find
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to search
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_find(array(1,2,3),2)
</code>
→
<code>
1
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_first"><a href="#arrays-array_first-idx">
function array_first
</a></h3>
<div class="description">
<p>
Returns the first value of an array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_first
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_first(array('a','b','c'))
</code>
→
<code>
'a'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_foreach"><a href="#arrays-array_foreach-idx">
function array_foreach
</a></h3>
<div class="description">
<p>
Returns an array with the given expression evaluated on each item.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_foreach
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
expression
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
expression
</td>
<td>
an expression to evaluate on each item. The variable `@element` will be replaced by the current value.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_foreach(array('a','b','c'),upper(@element))
</code>
→
<code>
[ 'A', 'B', 'C' ]
</code>
</li>
<li>
<code>
array_foreach(array(1,2,3),@element + 10)
</code>
→
<code>
[ 11, 12, 13 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_get"><a href="#arrays-array_get-idx">
function array_get
</a></h3>
<div class="description">
<p>
Returns the Nth value (0 for the first one) of an array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_get
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
index
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
index
</td>
<td>
the index to get (0 based)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_get(array('a','b','c'),1)
</code>
→
<code>
'b'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_insert"><a href="#arrays-array_insert-idx">
function array_insert
</a></h3>
<div class="description">
<p>
Returns an array with the given value added at the given position.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_insert
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
pos
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
pos
</td>
<td>
the position where to add (0 based)
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to add
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_insert(array(1,2,3),1,100)
</code>
→
<code>
[ 1, 100, 2, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_intersect"><a href="#arrays-array_intersect-idx">
function array_intersect
</a></h3>
<div class="description">
<p>
Returns true if at least one element of array1 exists in array2.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_intersect
</span>
(
<span class="argument">
array1
</span>
,
<span class="argument">
array2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array1
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
array2
</td>
<td>
another array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_intersect(array(1,2,3,4),array(4,0,2,5))
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_last"><a href="#arrays-array_last-idx">
function array_last
</a></h3>
<div class="description">
<p>
Returns the last value of an array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_last
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_last(array('a','b','c'))
</code>
→
<code>
'c'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_length"><a href="#arrays-array_length-idx">
function array_length
</a></h3>
<div class="description">
<p>
Returns the number of elements of an array.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_length
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_length(array(1,2,3))
</code>
→
<code>
3
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_prepend"><a href="#arrays-array_prepend-idx">
function array_prepend
</a></h3>
<div class="description">
<p>
Returns an array with the given value added at the beginning.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_prepend
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to add
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_prepend(array(1,2,3),0)
</code>
→
<code>
[ 0, 1, 2, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_remove_all"><a href="#arrays-array_remove_all-idx">
function array_remove_all
</a></h3>
<div class="description">
<p>
Returns an array with all the entries of the given value removed.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_remove_all
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the values to remove
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_remove_all(array('a','b','c','b'),'b')
</code>
→
<code>
[ 'a', 'c' ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_remove_at"><a href="#arrays-array_remove_at-idx">
function array_remove_at
</a></h3>
<div class="description">
<p>
Returns an array with the given index removed.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_remove_at
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
pos
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
pos
</td>
<td>
the position to remove (0 based)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_remove_at(array(1,2,3),1)
</code>
→
<code>
[ 1, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_reverse"><a href="#arrays-array_reverse-idx">
function array_reverse
</a></h3>
<div class="description">
<p>
Returns the given array with array values in reversed order.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_reverse
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_reverse(array(2,4,0,10))
</code>
→
<code>
[ 10, 0, 4, 2 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_slice"><a href="#arrays-array_slice-idx">
function array_slice
</a></h3>
<div class="description">
<p>
Returns a portion of the array. The slice is defined by the start_pos and end_pos arguments.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_slice
</span>
(
<span class="argument">
array
</span>
,
<span class="argument">
start_pos
</span>
,
<span class="argument">
end_pos
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
start_pos
</td>
<td>
the index of the start position of the slice (0 based). The start_pos index is included in the slice. If you use a negative start_pos, the index is counted from the end of the list (-1 based).
</td>
</tr>
<tr>
<td class="argument">
end_pos
</td>
<td>
the index of the end position of the slice (0 based). The end_pos index is included in the slice. If you use a negative end_pos, the index is counted from the end of the list (-1 based).
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_slice(array(1,2,3,4,5),0,3)
</code>
→
<code>
[ 1, 2, 3, 4 ]
</code>
</li>
<li>
<code>
array_slice(array(1,2,3,4,5),0,-1)
</code>
→
<code>
[ 1, 2, 3, 4, 5 ]
</code>
</li>
<li>
<code>
array_slice(array(1,2,3,4,5),-5,-1)
</code>
→
<code>
[ 1, 2, 3, 4, 5 ]
</code>
</li>
<li>
<code>
array_slice(array(1,2,3,4,5),0,0)
</code>
→
<code>
[ 1 ]
</code>
</li>
<li>
<code>
array_slice(array(1,2,3,4,5),-2,-1)
</code>
→
<code>
[ 4, 5 ]
</code>
</li>
<li>
<code>
array_slice(array(1,2,3,4,5),-1,-1)
</code>
→
<code>
[ 5 ]
</code>
</li>
<li>
<code>
array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),1,2)
</code>
→
<code>
[ 'Valmiera', 'Chugiak' ]
</code>
</li>
<li>
<code>
array_slice(array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),-2,-1)
</code>
→
<code>
[ 'Chugiak', 'Brighton' ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_sort"><a href="#arrays-array_sort-idx">
function array_sort
</a></h3>
<div class="description">
<p>
Returns the provided array with its elements sorted.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_sort
</span>
(
<span class="argument">
array
</span>
[,
<span class="argument">
ascending=true
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
an array
</td>
</tr>
<tr>
<td class="argument">
ascending
</td>
<td>
set this parameter to false to sort the array in descending order
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_sort(array(3,2,1))
</code>
→
<code>
[ 1, 2, 3 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-array_to_string"><a href="#arrays-array_to_string-idx">
function array_to_string
</a></h3>
<div class="description">
<p>
Concatenates array elements into a string separated by a delimiter and using optional string for empty values.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
array_to_string
</span>
(
<span class="argument">
array
</span>
[,
<span class="argument">
delimiter=','
</span>
][,
<span class="argument">
empty_value=''
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
the input array
</td>
</tr>
<tr>
<td class="argument">
delimiter
</td>
<td>
the string delimiter used to separate concatenated array elements
</td>
</tr>
<tr>
<td class="argument">
empty_value
</td>
<td>
the optional string to use as replacement for empty (zero length) matches
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
array_to_string(array('1','2','3'))
</code>
→
<code>
'1,2,3'
</code>
</li>
<li>
<code>
array_to_string(array(1,2,3),'-')
</code>
→
<code>
'1-2-3'
</code>
</li>
<li>
<code>
array_to_string(array('1','','3'),',','0')
</code>
→
<code>
'1,0,3'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-generate_series"><a href="#arrays-generate_series-idx">
function generate_series
</a></h3>
<div class="description">
<p>
Creates an array containing a sequence of numbers.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
generate_series
</span>
(
<span class="argument">
start
</span>
,
<span class="argument">
stop
</span>
[,
<span class="argument">
step=1
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
start
</td>
<td>
first value of the sequence
</td>
</tr>
<tr>
<td class="argument">
stop
</td>
<td>
value that ends the sequence once reached
</td>
</tr>
<tr>
<td class="argument">
step
</td>
<td>
value used as the increment between values
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
generate_series(1,5)
</code>
→
<code>
[ 1, 2, 3, 4, 5 ]
</code>
</li>
<li>
<code>
generate_series(5,1,-1)
</code>
→
<code>
[ 5, 4, 3, 2, 1 ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-regexp_matches"><a href="#arrays-regexp_matches-idx">
function regexp_matches
</a></h3>
<div class="description">
<p>
Returns an array of all strings captured by capturing groups, in the order the groups themselves appear in the supplied regular expression against a string.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
regexp_matches
</span>
(
<span class="argument">
string
</span>
,
<span class="argument">
regex
</span>
[,
<span class="argument">
empty_value=''
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
the string to capture groups from against the regular expression
</td>
</tr>
<tr>
<td class="argument">
regex
</td>
<td>
the regular expression used to capture groups
</td>
</tr>
<tr>
<td class="argument">
empty_value
</td>
<td>
the optional string to use as replacement for empty (zero length) matches
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
regexp_matches('QGIS=&gt;rocks','(.*)=&gt;(.*)')
</code>
→
<code>
[ 'QGIS', 'rocks' ]
</code>
</li>
<li>
<code>
regexp_matches('key=&gt;','(.*)=&gt;(.*)','empty value')
</code>
→
<code>
[ 'key', 'empty value' ]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="arrays-string_to_array"><a href="#arrays-string_to_array-idx">
function string_to_array
</a></h3>
<div class="description">
<p>
Splits string into an array using supplied delimiter and optional string for empty values.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
string_to_array
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
delimiter=','
</span>
][,
<span class="argument">
empty_value=''
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
the input string
</td>
</tr>
<tr>
<td class="argument">
delimiter
</td>
<td>
the string delimiter used to split the input string
</td>
</tr>
<tr>
<td class="argument">
empty_value
</td>
<td>
the optional string to use as replacement for empty (zero length) matches
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
string_to_array('1,2,3',',')
</code>
→
<code>
[ '1', '2', '3' ]
</code>
</li>
<li>
<code>
string_to_array('1,,3',',','0')
</code>
→
<code>
[ '1', '0', '3' ]
</code>
</li>
</ul>
</div>
</div></div>
<div id="color" class="group"><h2><a href="#color-idx">group color</a></h2>
<div class="description"><p>This group contains functions for manipulating colors</p></div></div>
<div class="function"><h3 id="color-color_cmyk"><a href="#color-color_cmyk-idx">
function color_cmyk
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its cyan, magenta, yellow and black components
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_cmyk
</span>
(
<span class="argument">
cyan
</span>
,
<span class="argument">
magenta
</span>
,
<span class="argument">
yellow
</span>
,
<span class="argument">
black
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
cyan
</td>
<td>
cyan component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
magenta
</td>
<td>
magenta component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
yellow
</td>
<td>
yellow component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
black
</td>
<td>
black component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_cmyk(100,50,0,10)
</code>
→
<code>
0,115,230
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_cmyka"><a href="#color-color_cmyka-idx">
function color_cmyka
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its cyan, magenta, yellow, black and alpha (transparency) components
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_cmyka
</span>
(
<span class="argument">
cyan
</span>
,
<span class="argument">
magenta
</span>
,
<span class="argument">
yellow
</span>
,
<span class="argument">
black
</span>
,
<span class="argument">
alpha
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
cyan
</td>
<td>
cyan component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
magenta
</td>
<td>
magenta component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
yellow
</td>
<td>
yellow component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
black
</td>
<td>
black component of the color, as a percentage integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
alpha
</td>
<td>
alpha component as an integer value from 0 (completely transparent) to 255 (opaque).
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_cmyk(100,50,0,10,200)
</code>
→
<code>
0,115,230,200
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_grayscale_average"><a href="#color-color_grayscale_average-idx">
function color_grayscale_average
</a></h3>
<div class="description">
<p>
Applies a grayscale filter and returns a string representation from a provided color.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_grayscale_average
</span>
(
<span class="argument">
color
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color
</td>
<td>
a color string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_grayscale_average('255,100,50')
</code>
→
<code>
127,127,127,255
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_hsl"><a href="#color-color_hsl-idx">
function color_hsl
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its hue, saturation, and lightness attributes.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_hsl
</span>
(
<span class="argument">
hue
</span>
,
<span class="argument">
saturation
</span>
,
<span class="argument">
lightness
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
hue
</td>
<td>
hue of the color, as an integer value from 0 to 360
</td>
</tr>
<tr>
<td class="argument">
saturation
</td>
<td>
saturation percentage of the color as an integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
lightness
</td>
<td>
lightness percentage of the color as an integer value from 0 to 100
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_hsl(100,50,70)
</code>
→
<code>
166,217,140
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_hsla"><a href="#color-color_hsla-idx">
function color_hsla
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its hue, saturation, lightness and alpha (transparency) attributes
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_hsla
</span>
(
<span class="argument">
hue
</span>
,
<span class="argument">
saturation
</span>
,
<span class="argument">
lightness
</span>
,
<span class="argument">
alpha
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
hue
</td>
<td>
hue of the color, as an integer value from 0 to 360
</td>
</tr>
<tr>
<td class="argument">
saturation
</td>
<td>
saturation percentage of the color as an integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
lightness
</td>
<td>
lightness percentage of the color as an integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
alpha
</td>
<td>
alpha component as an integer value from 0 (completely transparent) to 255 (opaque).
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_hsla(100,50,70,200)
</code>
→
<code>
166,217,140,200
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_hsv"><a href="#color-color_hsv-idx">
function color_hsv
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its hue, saturation, and value attributes.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_hsv
</span>
(
<span class="argument">
hue
</span>
,
<span class="argument">
saturation
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
hue
</td>
<td>
hue of the color, as an integer value from 0 to 360
</td>
</tr>
<tr>
<td class="argument">
saturation
</td>
<td>
saturation percentage of the color as an integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
value percentage of the color as an integer from 0 to 100
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_hsv(40,100,100)
</code>
→
<code>
255,170,0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_hsva"><a href="#color-color_hsva-idx">
function color_hsva
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its hue, saturation, value and alpha (transparency) attributes.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_hsva
</span>
(
<span class="argument">
hue
</span>
,
<span class="argument">
saturation
</span>
,
<span class="argument">
value
</span>
,
<span class="argument">
alpha
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
hue
</td>
<td>
hue of the color, as an integer value from 0 to 360
</td>
</tr>
<tr>
<td class="argument">
saturation
</td>
<td>
saturation percentage of the color as an integer value from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
value percentage of the color as an integer from 0 to 100
</td>
</tr>
<tr>
<td class="argument">
alpha
</td>
<td>
alpha component as an integer value from 0 (completely transparent) to 255 (opaque)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_hsva(40,100,100,200)
</code>
→
<code>
255,170,0,200
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_mix_rgb"><a href="#color-color_mix_rgb-idx">
function color_mix_rgb
</a></h3>
<div class="description">
<p>
Returns a string representing a color mixing the red, green, blue, and alpha values of two provided colors based on a given ratio.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_mix_rgb
</span>
(
<span class="argument">
color1
</span>
,
<span class="argument">
color2
</span>
,
<span class="argument">
ratio
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color1
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
color2
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
ratio
</td>
<td>
a ratio
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_mix_rgb('0,0,0','255,255,255',0.5)
</code>
→
<code>
127,127,127,255
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_part"><a href="#color-color_part-idx">
function color_part
</a></h3>
<div class="description">
<p>
Returns a specific component from a color string, e.g., the red component or alpha component.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_part
</span>
(
<span class="argument">
color
</span>
,
<span class="argument">
component
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
component
</td>
<td>
a string corresponding to the color component to return. Valid options are:
<br/>
<ul>
<li>
red: RGB red component (0-255)
</li>
<li>
green: RGB green component (0-255)
</li>
<li>
blue: RGB blue component (0-255)
</li>
<li>
alpha: alpha (transparency) value (0-255)
</li>
<li>
hue: HSV hue (0-360)
</li>
<li>
saturation: HSV saturation (0-100)
</li>
<li>
value: HSV value (0-100)
</li>
<li>
hsl_hue: HSL hue (0-360)
</li>
<li>
hsl_saturation: HSL saturation (0-100)
</li>
<li>
lightness: HSL lightness (0-100)
</li>
<li>
cyan: CMYK cyan component (0-100)
</li>
<li>
magenta: CMYK magenta component (0-100)
</li>
<li>
yellow: CMYK yellow component (0-100)
</li>
<li>
black: CMYK black component (0-100)
</li>
</ul>
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_part('200,10,30','green')
</code>
→
<code>
10
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_rgb"><a href="#color-color_rgb-idx">
function color_rgb
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its red, green, and blue components.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_rgb
</span>
(
<span class="argument">
red
</span>
,
<span class="argument">
green
</span>
,
<span class="argument">
blue
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
red
</td>
<td>
red component as an integer value from 0 to 255
</td>
</tr>
<tr>
<td class="argument">
green
</td>
<td>
green component as an integer value from 0 to 255
</td>
</tr>
<tr>
<td class="argument">
blue
</td>
<td>
blue component as an integer value from 0 to 255
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_rgb(255,127,0)
</code>
→
<code>
255,127,0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-color_rgba"><a href="#color-color_rgba-idx">
function color_rgba
</a></h3>
<div class="description">
<p>
Returns a string representation of a color based on its red, green, blue, and alpha (transparency) components.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
color_rgba
</span>
(
<span class="argument">
red
</span>
,
<span class="argument">
green
</span>
,
<span class="argument">
blue
</span>
,
<span class="argument">
alpha
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
red
</td>
<td>
red component as an integer value from 0 to 255
</td>
</tr>
<tr>
<td class="argument">
green
</td>
<td>
green component as an integer value from 0 to 255
</td>
</tr>
<tr>
<td class="argument">
blue
</td>
<td>
blue component as an integer value from 0 to 255
</td>
</tr>
<tr>
<td class="argument">
alpha
</td>
<td>
alpha component as an integer value from 0 (completely transparent) to 255 (opaque).
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
color_rgba(255,127,0,200)
</code>
→
<code>
255,127,0,200
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-create_ramp"><a href="#color-create_ramp-idx">
function create_ramp
</a></h3>
<div class="description">
<p>
Returns a gradient ramp from a map of color strings and steps.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
create_ramp
</span>
(
<span class="argument">
map
</span>
[,
<span class="argument">
discrete
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
map
</td>
<td>
a map of color strings and steps
</td>
</tr>
<tr>
<td class="argument">
discrete
</td>
<td>
declare whether the color ramp is discrete
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
ramp_color(create_array(map(0,'0,0,0',1,'255,0,0')),1)
</code>
→
<code>
'255,0,0,255'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-darker"><a href="#color-darker-idx">
function darker
</a></h3>
<div class="description">
<p>
Returns a darker (or lighter) color string
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
darker
</span>
(
<span class="argument">
color
</span>
,
<span class="argument">
factor
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
factor
</td>
<td>
a integer number corresponding to the darkening factor:
<ul>
<li>
if the factor is greater than 100, this functions returns a darker color (for e.g., setting factor to 300 returns a color that has one-third the brightness);
</li>
<li>
if the factor is less than 100, the return color is lighter, but using the lighter() function for this purpose is recommended;
</li>
<li>
if the factor is 0 or negative, the return value is unspecified.
</li>
</ul>
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
darker('200,10,30',300)
</code>
→
<code>
'66,3,10,255'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-lighter"><a href="#color-lighter-idx">
function lighter
</a></h3>
<div class="description">
<p>
Returns a lighter (or darker) color string
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
lighter
</span>
(
<span class="argument">
color
</span>
,
<span class="argument">
factor
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
factor
</td>
<td>
a integer number corresponding to the lightening factor:
<ul>
<li>
if the factor is greater than 100, this functions returns a lighter color (for e.g., setting factor to 150 returns a color that is 50% brighter);
</li>
<li>
if the factor is less than 100, the return color is darker, but using the darker() function for this purpose is recommended;
</li>
<li>
if the factor is 0 or negative, the return value is unspecified.
</li>
</ul>
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
lighter('200,10,30',200)
</code>
→
<code>
'255,158,168,255'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-project_color"><a href="#color-project_color-idx">
function project_color
</a></h3>
<div class="description">
<p>
Returns a color from the project's color scheme.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
project_color
</span>
(
<span class="argument">
name
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
name
</td>
<td>
a color name
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
project_color('Logo color')
</code>
→
<code>
20,140,50
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-ramp_color"><a href="#color-ramp_color-idx">
function ramp_color
</a></h3>
<div class="description">
<p>
Returns a string representing a color from a color ramp.
</p>
</div>
<h3 id="color-ramp_color"><a href="#color-ramp_color-idx">
Saved ramp variant
</a></h3>
<div class="description">
Returns a string representing a color from a saved ramp
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
ramp_color
</span>
(
<span class="argument">
ramp_name
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
ramp_name
</td>
<td>
the name of the color ramp as a string, for example 'Spectral'
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the position on the ramp to select the color from as a real number between 0 and 1
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
ramp_color('Spectral',0.3)
</code>
→
<code>
'253,190,115,255'
</code>
</li>
</ul>
</div>
<h4>
Notes
</h4>
<div class="notes">
<p>
The color ramps available vary between QGIS installations. This function may not give the expected results if you move your QGIS project between installations.
</p>
</div>
<h3 id="color-ramp_color"><a href="#color-ramp_color-idx">
Expression-created ramp variant
</a></h3>
<div class="description">
Returns a string representing a color from an expression-created ramp
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
ramp_color
</span>
(
<span class="argument">
ramp
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
ramp
</td>
<td>
the color ramp
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the position on the ramp to select the color from as a real number between 0 and 1
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
ramp_color(create_ramp(map(0,'0,0,0',1,'255,0,0')),1)
</code>
→
<code>
'255,0,0,255'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="color-set_color_part"><a href="#color-set_color_part-idx">
function set_color_part
</a></h3>
<div class="description">
<p>
Sets a specific color component for a color string, e.g., the red component or alpha component.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
set_color_part
</span>
(
<span class="argument">
color
</span>
,
<span class="argument">
component
</span>
,
<span class="argument">
value
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
color
</td>
<td>
a color string
</td>
</tr>
<tr>
<td class="argument">
component
</td>
<td>
a string corresponding to the color component to set. Valid options are:
<br/>
<ul>
<li>
red: RGB red component (0-255)
</li>
<li>
green: RGB green component (0-255)
</li>
<li>
blue: RGB blue component (0-255)
</li>
<li>
alpha: alpha (transparency) value (0-255)
</li>
<li>
hue: HSV hue (0-360)
</li>
<li>
saturation: HSV saturation (0-100)
</li>
<li>
value: HSV value (0-100)
</li>
<li>
hsl_hue: HSL hue (0-360)
</li>
<li>
hsl_saturation: HSL saturation (0-100)
</li>
<li>
lightness: HSL lightness (0-100)
</li>
<li>
cyan: CMYK cyan component (0-100)
</li>
<li>
magenta: CMYK magenta component (0-100)
</li>
<li>
yellow: CMYK yellow component (0-100)
</li>
<li>
black: CMYK black component (0-100)
</li>
</ul>
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
new value for color component, respecting the ranges listed above
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
set_color_part('200,10,30','green',50)
</code>
→
<code>
200,50,30
</code>
</li>
</ul>
</div>
</div></div>
<div id="conditionals" class="group"><h2><a href="#conditionals-idx">group conditionals</a></h2>
<div class="description"><p>This group contains functions to handle conditional checks in expressions.</p></div></div>
<div class="function"><h3 id="conditionals-coalesce"><a href="#conditionals-coalesce-idx">
function coalesce
</a></h3>
<div class="description">
<p>
Returns the first non-NULL value from the expression list.
<br/>
This function can take any number of arguments.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
coalesce
</span>
(
<span class="argument">
expression1
</span>
,
<span class="argument">
expression2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
any valid expression or value, regardless of type.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
coalesce(NULL, 2)
</code>
→
<code>
2
</code>
</li>
<li>
<code>
coalesce(NULL, 2, 3)
</code>
→
<code>
2
</code>
</li>
<li>
<code>
coalesce(7, NULL, 3*2)
</code>
→
<code>
7
</code>
</li>
<li>
<code>
coalesce("fieldA", "fallbackField", 'ERROR')
</code>
→
<code>
value of fieldA if it is non-NULL else the value of "fallbackField" or the string 'ERROR' if both are NULL
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conditionals-if"><a href="#conditionals-if-idx">
function if
</a></h3>
<div class="description">
<p>
Tests a condition and returns a different result depending on the conditional check.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
if
</span>
(
<span class="argument">
condition
</span>
,
<span class="argument">
result_when_true
</span>
,
<span class="argument">
result_when_false
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
condition
</td>
<td>
the condition which should be checked
</td>
</tr>
<tr>
<td class="argument">
result_when_true
</td>
<td>
the result which will be returned when the condition is true or another value that does not convert to false.
</td>
</tr>
<tr>
<td class="argument">
result_when_false
</td>
<td>
the result which will be returned when the condition is false or another value that converts to false like 0 or ''. NULL will also be converted to false.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
if( 1+1=2, 'Yes', 'No' )
</code>
→
<code>
'Yes'
</code>
</li>
<li>
<code>
if( 1+1=3, 'Yes', 'No' )
</code>
→
<code>
'No'
</code>
</li>
<li>
<code>
if( 5 &gt; 3, 1, 0)
</code>
→
<code>
1
</code>
</li>
<li>
<code>
if( '', 'It is true (not empty)', 'It is false (empty)' )
</code>
→
<code>
'It is false (empty)'
</code>
</li>
<li>
<code>
if( ' ', 'It is true (not empty)', 'It is false (empty)' )
</code>
→
<code>
'It is true (not empty)'
</code>
</li>
<li>
<code>
if( 0, 'One', 'Zero' )
</code>
→
<code>
'Zero'
</code>
</li>
<li>
<code>
if( 10, 'One', 'Zero' )
</code>
→
<code>
'One'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conditionals-nullif"><a href="#conditionals-nullif-idx">
function nullif
</a></h3>
<div class="description">
<p>
Returns a null value if value1 equals value2; otherwise it returns value1. This can be used to conditionally substitute values with NULL.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
nullif
</span>
(
<span class="argument">
value1
</span>
,
<span class="argument">
value2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
value1
</td>
<td>
The value that should either be used or substituted with NULL.
</td>
</tr>
<tr>
<td class="argument">
value2
</td>
<td>
The control value that will trigger the NULL substitution.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
nullif('(none)', '(none)')
</code>
→
<code>
NULL
</code>
</li>
<li>
<code>
nullif('text', '(none)')
</code>
→
<code>
'text'
</code>
</li>
<li>
<code>
nullif("name", '')
</code>
→
<code>
NULL, if name is an empty string (or already NULL), the name in any other case.
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conditionals-regexp_match"><a href="#conditionals-regexp_match-idx">
function regexp_match
</a></h3>
<div class="description">
<p>
Return the first matching position matching a regular expression within a string, or 0 if the substring is not found.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
regexp_match
</span>
(
<span class="argument">
input_string
</span>
,
<span class="argument">
regex
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
input_string
</td>
<td>
the string to test against the regular expression
</td>
</tr>
<tr>
<td class="argument">
regex
</td>
<td>
The regular expression to test against. Backslash characters must be double escaped (e.g., "\\s" to match a white space character).
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
regexp_match('QGIS ROCKS','\\sROCKS')
</code>
→
<code>
4
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conditionals-try"><a href="#conditionals-try-idx">
function try
</a></h3>
<div class="description">
<p>
Tries an expression and returns its value if error-free. If the expression returns an error, an alternative value will be returned when provided otherwise the function will return null.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
try
</span>
(
<span class="argument">
expression
</span>
[,
<span class="argument">
alternative
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
the expression which should be run
</td>
</tr>
<tr>
<td class="argument">
alternative
</td>
<td>
the result which will be returned if the expression returns an error.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
try( to_int( '1' ), 0 )
</code>
→
<code>
1
</code>
</li>
<li>
<code>
try( to_int( 'a' ), 0 )
</code>
→
<code>
0
</code>
</li>
<li>
<code>
try( to_date( 'invalid_date' ) )
</code>
→
<code>
NULL
</code>
</li>
</ul>
</div>
</div></div>
<div id="conversions" class="group"><h2><a href="#conversions-idx">group conversions</a></h2>
<div class="description"><p>This group contains functions to convert on data type to another e.g string to integer, integer to string.</p></div></div>
<div class="function"><h3 id="conversions-hash"><a href="#conversions-hash-idx">
function hash
</a></h3>
<div class="description">
<p>
Creates a hash from a string with a given method.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
hash
</span>
(
<span class="argument">
string
</span>
,
<span class="argument">
method
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
the string to hash
</td>
</tr>
<tr>
<td class="argument">
method
</td>
<td>
The hash method among 'md4', 'md5', 'sha1', 'sha224', 'sha384', 'sha512', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'keccak_224', 'keccak_256', 'keccak_384', 'keccak_512'
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
hash('QGIS', md4)
</code>
→
<code>
'c0fc71c241cdebb6e888cbac0e2b68eb'
</code>
</li>
<li>
<code>
hash('QGIS', md5)
</code>
→
<code>
'57470aaa9e22adaefac7f5f342f1c6da'
</code>
</li>
<li>
<code>
hash('QGIS', sha1)
</code>
→
<code>
'f87cfb2b74cdd5867db913237024e7001e62b114'
</code>
</li>
<li>
<code>
hash('QGIS', sha224)
</code>
→
<code>
'4093a619ada631c770f44bc643ead18fb393b93d6a6af1861fcfece0'
</code>
</li>
<li>
<code>
hash('QGIS', sha256)
</code>
→
<code>
'eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309'
</code>
</li>
<li>
<code>
hash('QGIS', sha384)
</code>
→
<code>
'91c1de038cc3d09fdd512e99f9dd9922efadc39ed21d3922e69a4305cc25506033aee388e554b78714c8734f9cd7e610'
</code>
</li>
<li>
<code>
hash('QGIS', sha512)
</code>
→
<code>
'c2c092f2ab743bf8edbeb6d028a745f30fc720408465ed369421f0a4e20fa5e27f0c90ad72d3f1d836eaa5d25cd39897d4cf77e19984668ef58da6e3159f18ac'
</code>
</li>
<li>
<code>
hash('QGIS', sha3_224)
</code>
→
<code>
'467f49a5039e7280d5d42fd433e80d203439e338eaabd701f0d6c17d'
</code>
</li>
<li>
<code>
hash('QGIS', sha3_256)
</code>
→
<code>
'540f7354b6b8a6e735f2845250f15f4f3ba4f666c55574d9e9354575de0e980f'
</code>
</li>
<li>
<code>
hash('QGIS', sha3_384)
</code>
→
<code>
'96052da1e77679e9a65f60d7ead961b287977823144786386eb43647b0901fd8516fa6f1b9d243fb3f28775e6dde6107'
</code>
</li>
<li>
<code>
hash('QGIS', sha3_512)
</code>
→
<code>
'900d079dc69761da113980253aa8ac0414a8bd6d09879a916228f8743707c4758051c98445d6b8945ec854ff90655005e02aceb0a2ffc6a0ebf818745d665349'
</code>
</li>
<li>
<code>
hash('QGIS', keccak_224)
</code>
→
<code>
'5b0ce6acef8b0a121d4ac4f3eaa8503c799ad4e26a3392d1fb201478'
</code>
</li>
<li>
<code>
hash('QGIS', keccak_256)
</code>
→
<code>
'991c520aa6815392de24087f61b2ae0fd56abbfeee4a8ca019c1011d327c577e'
</code>
</li>
<li>
<code>
hash('QGIS', keccak_384)
</code>
→
<code>
'c57a3aed9d856fa04e5eeee9b62b6e027cca81ba574116d3cc1f0d48a1ef9e5886ff463ea8d0fac772ee473bf92f810d'
</code>
</li>
<li>
<code>
keccak_512('QGIS')
</code>
→
<code>
'6f0f751776b505e317de222508fa5d3ed7099d8f07c74fed54ccee6e7cdc6b89b4a085e309f2ee5210c9'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-md5"><a href="#conversions-md5-idx">
function md5
</a></h3>
<div class="description">
<p>
Creates a md5 hash from a string.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
md5
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
the string to hash
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
md5('QGIS')
</code>
→
<code>
'57470aaa9e22adaefac7f5f342f1c6da'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-sha256"><a href="#conversions-sha256-idx">
function sha256
</a></h3>
<div class="description">
<p>
Creates a sha256 hash from a string.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
sha256
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
the string to hash
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
sha256('QGIS')
</code>
→
<code>
'eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_date"><a href="#conversions-to_date-idx">
function to_date
</a></h3>
<div class="description">
<p>
Converts a string into a date object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qdate.html#fromString-1">
QDate::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_date
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a date value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a date
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a date
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_date('2012-05-04')
</code>
→
<code>
2012-05-04
</code>
</li>
<li>
<code>
to_date('June 29, 2019','MMMM d, yyyy')
</code>
→
<code>
2019-06-29
</code>
</li>
<li>
<code>
to_date('29 juin, 2019','d MMMM, yyyy','fr')
</code>
→
<code>
2019-06-29
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_datetime"><a href="#conversions-to_datetime-idx">
function to_datetime
</a></h3>
<div class="description">
<p>
Converts a string into a datetime object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qdatetime.html#fromString-1">
QDateTime::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_datetime
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a datetime value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a datetime
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a datetime
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_datetime('2012-05-04 12:50:00')
</code>
→
<code>
2012-05-04T12:50:00
</code>
</li>
<li>
<code>
to_datetime('June 29, 2019 @ 12:34','MMMM d, yyyy @ HH:mm')
</code>
→
<code>
2019-06-29T12:34
</code>
</li>
<li>
<code>
to_datetime('29 juin, 2019 @ 12:34','d MMMM, yyyy @ HH:mm','fr')
</code>
→
<code>
2019-06-29T12:34
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_dm"><a href="#conversions-to_dm-idx">
function to_dm
</a></h3>
<div class="description">
<p>
Convert a coordinate to degree, minute.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_dm
</span>
(
<span class="argument">
coordinate
</span>
,
<span class="argument">
axis
</span>
,
<span class="argument">
precision
</span>
[,
<span class="argument">
formatting
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
coordinate
</td>
<td>
A latitude or longitude value.
</td>
</tr>
<tr>
<td class="argument">
axis
</td>
<td>
The axis of the coordinate. Either 'x' or 'y'.
</td>
</tr>
<tr>
<td class="argument">
precision
</td>
<td>
Number of decimals.
</td>
</tr>
<tr>
<td class="argument">
formatting
</td>
<td>
Designates the formatting type. Acceptable values are NULL, 'aligned' or 'suffix'.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_dm(6.3545681, 'x', 3)
</code>
→
<code>
6°21.274′
</code>
</li>
<li>
<code>
to_dm(6.3545681, 'y', 4, 'suffix')
</code>
→
<code>
6°21.2741′N
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_dms"><a href="#conversions-to_dms-idx">
function to_dms
</a></h3>
<div class="description">
<p>
Convert a coordinate to degree, minute, second.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_dms
</span>
(
<span class="argument">
coordinate
</span>
,
<span class="argument">
axis
</span>
,
<span class="argument">
precision
</span>
[,
<span class="argument">
formatting
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
coordinate
</td>
<td>
A latitude or longitude value.
</td>
</tr>
<tr>
<td class="argument">
axis
</td>
<td>
The axis of the coordinate. Either 'x' or 'y'.
</td>
</tr>
<tr>
<td class="argument">
precision
</td>
<td>
Number of decimals.
</td>
</tr>
<tr>
<td class="argument">
formatting
</td>
<td>
Designates the formatting type. Acceptable values are NULL, 'aligned' or 'suffix'.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_dms(6.3545681, 'x', 3)
</code>
→
<code>
6°21′16.445″
</code>
</li>
<li>
<code>
to_dms(6.3545681, 'y', 4, 'suffix')
</code>
→
<code>
6°21′16.4452″N
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_int"><a href="#conversions-to_int-idx">
function to_int
</a></h3>
<div class="description">
<p>
Converts a string to integer number. Nothing is returned if a value cannot be converted to integer (e.g '123asd' is invalid).
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_int
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string to convert to integer number
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_int('123')
</code>
→
<code>
123
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_interval"><a href="#conversions-to_interval-idx">
function to_interval
</a></h3>
<div class="description">
<p>
Converts a string to a interval type. Can be used to take days, hours, month, etc of a date.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_interval
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
a string representing an interval. Allowable formats include {n} days {n} hours {n} months.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_datetime('2012-05-05 12:00:00') - to_interval('1 day 2 hours')
</code>
→
<code>
2012-05-04T10:00:00
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_real"><a href="#conversions-to_real-idx">
function to_real
</a></h3>
<div class="description">
<p>
Converts a string to a real number. Nothing is returned if a value cannot be converted to real (e.g '123.56asd' is invalid). Numbers are rounded after saving changes if the precision is smaller than the result of the conversion.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_real
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string to convert to real number
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_real('123.45')
</code>
→
<code>
123.45
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_string"><a href="#conversions-to_string-idx">
function to_string
</a></h3>
<div class="description">
<p>
Converts a number to string.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_string
</span>
(
<span class="argument">
number
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
number
</td>
<td>
Integer or real value. The number to convert to string.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_string(123)
</code>
→
<code>
'123'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="conversions-to_time"><a href="#conversions-to_time-idx">
function to_time
</a></h3>
<div class="description">
<p>
Converts a string into a time object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qtime.html#fromString-1">
QTime::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_time
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a time value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a time
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a time
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_time('12:30:01')
</code>
→
<code>
12:30:01
</code>
</li>
<li>
<code>
to_time('12:34','HH:mm')
</code>
→
<code>
12:34:00
</code>
</li>
<li>
<code>
to_time('12:34','HH:mm','fr')
</code>
→
<code>
12:34:00
</code>
</li>
</ul>
</div>
</div></div>
<div id="date-and-time" class="group"><h2><a href="#date-and-time-idx">group date and time</a></h2>
<div class="description"><p>This group contains functions for handling date and time data.</p></div></div>
<div class="function"><h3 id="date-and-time-age"><a href="#date-and-time-age-idx">
function age
</a></h3>
<div class="description">
<p>
Returns the difference between two dates or datetimes.
<br/>
The difference is returned as a
<code>
Interval
</code>
and needs to be used with one of the following functions in order to extract useful information:
<br>
<ul>
<li>
<code>
year
</code>
<li>
<code>
month
</code>
<li>
<code>
week
</code>
<li>
<code>
day
</code>
<li>
<code>
hour
</code>
<li>
<code>
minute
</code>
<li>
<code>
second
</code>
</li>
</li>
</li>
</li>
</li>
</li>
</li>
</ul>
</br>
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
age
</span>
(
<span class="argument">
datetime1
</span>
,
<span class="argument">
datetime2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
datetime1
</td>
<td>
a string, date or datetime representing the later date
</td>
</tr>
<tr>
<td class="argument">
datetime2
</td>
<td>
a string, date or datetime representing the earlier date
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
day(age('2012-05-12','2012-05-02'))
</code>
→
<code>
10
</code>
</li>
<li>
<code>
hour(age('2012-05-12','2012-05-02'))
</code>
→
<code>
240
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-datetime_from_epoch"><a href="#date-and-time-datetime_from_epoch-idx">
function datetime_from_epoch
</a></h3>
<div class="description">
<p>
Returns a datetime whose date and time are the number of milliseconds, msecs, that have passed since 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt.UTC), and converted to Qt.LocalTime.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
datetime_from_epoch
</span>
(
<span class="argument">
int
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
int
</td>
<td>
number (milliseconds)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
datetime_from_epoch(1483225200000)
</code>
→
<code>
2017-01-01T00:00:00
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-day"><a href="#date-and-time-day-idx">
function day
</a></h3>
<div class="description">
<p>
Extracts the day from a date, or the number of days from an interval.
</p>
</div>
<h3 id="date-and-time-day"><a href="#date-and-time-day-idx">
Date variant
</a></h3>
<div class="description">
Extracts the day from a date or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
day
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
a date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
day('2012-05-12')
</code>
→
<code>
12
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-day"><a href="#date-and-time-day-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in days of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
day
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of days from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
day(to_interval('3 days'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
day(to_interval('3 weeks 2 days'))
</code>
→
<code>
23
</code>
</li>
<li>
<code>
day(age('2012-01-01','2010-01-01'))
</code>
→
<code>
730
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-day_of_week"><a href="#date-and-time-day_of_week-idx">
function day_of_week
</a></h3>
<div class="description">
<p>
Returns the day of the week for a specified date or datetime. The returned value ranges from 0 to 6, where 0 corresponds to a Sunday and 6 to a Saturday.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
day_of_week
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
day_of_week(to_date('2015-09-21'))
</code>
→
<code>
1
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-epoch"><a href="#date-and-time-epoch-idx">
function epoch
</a></h3>
<div class="description">
<p>
Returns the interval in milliseconds between the unix epoch and a given date value.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
epoch
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
a date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
epoch(to_date('2017-01-01'))
</code>
→
<code>
1483203600000
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-format_date"><a href="#date-and-time-format_date-idx">
function format_date
</a></h3>
<div class="description">
<p>
Formats a date type or string into a custom string format. Uses Qt date/time format strings. See
<a href="https://doc.qt.io/qt-5/qdatetime.html#toString">
QDateTime::toString
</a>
.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
format_date
</span>
(
<span class="argument">
datetime
</span>
,
<span class="argument">
format
</span>
[,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
datetime
</td>
<td>
date, time or datetime value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
String template used to format the string.
<table>
<thead>
<tr>
<th>
Expression
</th>
<th>
Output
</th>
</tr>
</thead>
<tr valign="top">
<td>
d
</td>
<td>
the day as number without a leading zero (1 to 31)
</td>
</tr>
<tr valign="top">
<td>
dd
</td>
<td>
the day as number with a leading zero (01 to 31)
</td>
</tr>
<tr valign="top">
<td>
ddd
</td>
<td>
the abbreviated localized day name (e.g. 'Mon' to 'Sun')
</td>
</tr>
<tr valign="top">
<td>
dddd
</td>
<td>
the long localized day name (e.g. 'Monday' to 'Sunday')
</td>
</tr>
<tr valign="top">
<td>
M
</td>
<td>
the month as number without a leading zero (1-12)
</td>
</tr>
<tr valign="top">
<td>
MM
</td>
<td>
the month as number with a leading zero (01-12)
</td>
</tr>
<tr valign="top">
<td>
MMM
</td>
<td>
the abbreviated localized month name (e.g. 'Jan' to 'Dec')
</td>
</tr>
<tr valign="top">
<td>
MMMM
</td>
<td>
the long localized month name (e.g. 'January' to 'December')
</td>
</tr>
<tr valign="top">
<td>
yy
</td>
<td>
the year as two digit number (00-99)
</td>
</tr>
<tr valign="top">
<td>
yyyy
</td>
<td>
the year as four digit number
</td>
</tr>
</table>
<p>
These expressions may be used for the time part of the format string:
</p>
<table>
<thead>
<tr>
<th>
Expression
</th>
<th>
Output
</th>
</tr>
</thead>
<tr valign="top">
<td>
h
</td>
<td>
the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
</td>
</tr>
<tr valign="top">
<td>
hh
</td>
<td>
the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
</td>
</tr>
<tr valign="top">
<td>
H
</td>
<td>
the hour without a leading zero (0 to 23, even with AM/PM display)
</td>
</tr>
<tr valign="top">
<td>
HH
</td>
<td>
the hour with a leading zero (00 to 23, even with AM/PM display)
</td>
</tr>
<tr valign="top">
<td>
m
</td>
<td>
the minute without a leading zero (0 to 59)
</td>
</tr>
<tr valign="top">
<td>
mm
</td>
<td>
the minute with a leading zero (00 to 59)
</td>
</tr>
<tr valign="top">
<td>
s
</td>
<td>
the second without a leading zero (0 to 59)
</td>
</tr>
<tr valign="top">
<td>
ss
</td>
<td>
the second with a leading zero (00 to 59)
</td>
</tr>
<tr valign="top">
<td>
z
</td>
<td>
the milliseconds without trailing zeroes (0 to 999)
</td>
</tr>
<tr valign="top">
<td>
zzz
</td>
<td>
the milliseconds with trailing zeroes (000 to 999)
</td>
</tr>
<tr valign="top">
<td>
AP or A
</td>
<td>
interpret as an AM/PM time.
<i>
AP
</i>
must be either "AM" or "PM".
</td>
</tr>
<tr valign="top">
<td>
ap or a
</td>
<td>
Interpret as an AM/PM time.
<i>
ap
</i>
must be either "am" or "pm".
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to format the date into a custom string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
format_date('2012-05-15','dd.MM.yyyy')
</code>
→
<code>
'15.05.2012'
</code>
</li>
<li>
<code>
format_date('2012-05-15','d MMMM yyyy','fr')
</code>
→
<code>
'15 juin 2012'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-hour"><a href="#date-and-time-hour-idx">
function hour
</a></h3>
<div class="description">
<p>
Extracts the hour part from a datetime or time, or the number of hours from an interval.
</p>
</div>
<h3 id="date-and-time-hour"><a href="#date-and-time-hour-idx">
Time variant
</a></h3>
<div class="description">
Extracts the hour part from a time or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
hour
</span>
(
<span class="argument">
datetime
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
datetime
</td>
<td>
a time or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
hour('2012-07-22T13:24:57')
</code>
→
<code>
13
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-hour"><a href="#date-and-time-hour-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in hours of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
hour
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of hours from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
hour(tointerval('3 hours'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
hour(age('2012-07-22T13:00:00','2012-07-22T10:00:00'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
hour(age('2012-01-01','2010-01-01'))
</code>
→
<code>
17520
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-minute"><a href="#date-and-time-minute-idx">
function minute
</a></h3>
<div class="description">
<p>
Extracts the minutes part from a datetime or time, or the number of minutes from an interval.
</p>
</div>
<h3 id="date-and-time-minute"><a href="#date-and-time-minute-idx">
Time variant
</a></h3>
<div class="description">
Extracts the minutes part from a time or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
minute
</span>
(
<span class="argument">
datetime
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
datetime
</td>
<td>
a time or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
minute('2012-07-22T13:24:57')
</code>
→
<code>
24
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-minute"><a href="#date-and-time-minute-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in minutes of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
minute
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of minutes from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
minute(tointerval('3 minutes'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
minute(age('2012-07-22T00:20:00','2012-07-22T00:00:00'))
</code>
→
<code>
20
</code>
</li>
<li>
<code>
minute(age('2012-01-01','2010-01-01'))
</code>
→
<code>
1051200
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-month"><a href="#date-and-time-month-idx">
function month
</a></h3>
<div class="description">
<p>
Extracts the month part from a date, or the number of months from an interval.
</p>
</div>
<h3 id="date-and-time-month"><a href="#date-and-time-month-idx">
Date variant
</a></h3>
<div class="description">
Extracts the month part from a date or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
month
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
a date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
month('2012-05-12')
</code>
→
<code>
05
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-month"><a href="#date-and-time-month-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in months of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
month
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of months from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
month(to_interval('3 months'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
month(age('2012-01-01','2010-01-01'))
</code>
→
<code>
4.03333
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-now"><a href="#date-and-time-now-idx">
function now
</a></h3>
<div class="description">
<p>
Returns the current date and time. The function is static and will return consistent results while evaluating. The time returned is the time when the expression is prepared.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
now
</span>
()
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
now()
</code>
→
<code>
2012-07-22T13:24:57
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-second"><a href="#date-and-time-second-idx">
function second
</a></h3>
<div class="description">
<p>
Extracts the seconds part from a datetime or time, or the number of seconds from an interval.
</p>
</div>
<h3 id="date-and-time-second"><a href="#date-and-time-second-idx">
Time variant
</a></h3>
<div class="description">
Extracts the seconds part from a time or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
second
</span>
(
<span class="argument">
datetime
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
datetime
</td>
<td>
a time or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
second('2012-07-22T13:24:57')
</code>
→
<code>
57
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-second"><a href="#date-and-time-second-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in seconds of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
second
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of seconds from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
second(age('2012-07-22T00:20:00','2012-07-22T00:00:00'))
</code>
→
<code>
1200
</code>
</li>
<li>
<code>
second(age('2012-01-01','2010-01-01'))
</code>
→
<code>
63072000
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-to_date"><a href="#date-and-time-to_date-idx">
function to_date
</a></h3>
<div class="description">
<p>
Converts a string into a date object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qdate.html#fromString-1">
QDate::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_date
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a date value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a date
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a date
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_date('2012-05-04')
</code>
→
<code>
2012-05-04
</code>
</li>
<li>
<code>
to_date('June 29, 2019','MMMM d, yyyy')
</code>
→
<code>
2019-06-29
</code>
</li>
<li>
<code>
to_date('29 juin, 2019','d MMMM, yyyy','fr')
</code>
→
<code>
2019-06-29
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-to_datetime"><a href="#date-and-time-to_datetime-idx">
function to_datetime
</a></h3>
<div class="description">
<p>
Converts a string into a datetime object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qdatetime.html#fromString-1">
QDateTime::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_datetime
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a datetime value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a datetime
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a datetime
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_datetime('2012-05-04 12:50:00')
</code>
→
<code>
2012-05-04T12:50:00
</code>
</li>
<li>
<code>
to_datetime('June 29, 2019 @ 12:34','MMMM d, yyyy @ HH:mm')
</code>
→
<code>
2019-06-29T12:34
</code>
</li>
<li>
<code>
to_datetime('29 juin, 2019 @ 12:34','d MMMM, yyyy @ HH:mm','fr')
</code>
→
<code>
2019-06-29T12:34
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-to_interval"><a href="#date-and-time-to_interval-idx">
function to_interval
</a></h3>
<div class="description">
<p>
Converts a string to a interval type. Can be used to take days, hours, month, etc of a date.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_interval
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
a string representing an interval. Allowable formats include {n} days {n} hours {n} months.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_datetime('2012-05-05 12:00:00') - to_interval('1 day 2 hours')
</code>
→
<code>
2012-05-04T10:00:00
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-to_time"><a href="#date-and-time-to_time-idx">
function to_time
</a></h3>
<div class="description">
<p>
Converts a string into a time object. An optional format string can be provided to parse the string; see
<a href="https://doc.qt.io/qt-5/qtime.html#fromString-1">
QTime::fromString
</a>
for additional documentation on the format.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
to_time
</span>
(
<span class="argument">
string
</span>
[,
<span class="argument">
format
</span>
][,
<span class="argument">
language
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string representing a time value
</td>
</tr>
<tr>
<td class="argument">
format
</td>
<td>
format used to convert the string into a time
</td>
</tr>
<tr>
<td class="argument">
language
</td>
<td>
language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a time
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
to_time('12:30:01')
</code>
→
<code>
12:30:01
</code>
</li>
<li>
<code>
to_time('12:34','HH:mm')
</code>
→
<code>
12:34:00
</code>
</li>
<li>
<code>
to_time('12:34','HH:mm','fr')
</code>
→
<code>
12:34:00
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-week"><a href="#date-and-time-week-idx">
function week
</a></h3>
<div class="description">
<p>
Extracts the week number from a date, or the number of weeks from an interval.
</p>
</div>
<h3 id="date-and-time-week"><a href="#date-and-time-week-idx">
Date variant
</a></h3>
<div class="description">
Extracts the week number from a date or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
week
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
a date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
week('2012-05-12')
</code>
→
<code>
19
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-week"><a href="#date-and-time-week-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in weeks of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
week
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of months from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
week(to_interval('3 weeks'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
week(age('2012-01-01','2010-01-01'))
</code>
→
<code>
104.285
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="date-and-time-year"><a href="#date-and-time-year-idx">
function year
</a></h3>
<div class="description">
<p>
Extracts the year part from a date, or the number of years from an interval.
</p>
</div>
<h3 id="date-and-time-year"><a href="#date-and-time-year-idx">
Date variant
</a></h3>
<div class="description">
Extracts the year part from a date or datetime.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
year
</span>
(
<span class="argument">
date
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
date
</td>
<td>
a date or datetime value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
year('2012-05-12')
</code>
→
<code>
2012
</code>
</li>
</ul>
</div>
<h3 id="date-and-time-year"><a href="#date-and-time-year-idx">
Interval variant
</a></h3>
<div class="description">
Calculates the length in years of an interval.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
year
</span>
(
<span class="argument">
interval
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
interval
</td>
<td>
interval value to return number of years from
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
year(to_interval('3 years'))
</code>
→
<code>
3
</code>
</li>
<li>
<code>
year(age('2012-01-01','2010-01-01'))
</code>
→
<code>
1.9986
</code>
</li>
</ul>
</div>
</div></div>
<div id="files-and-paths" class="group"><h2><a href="#files-and-paths-idx">group files and paths</a></h2>
<div class="description"><p>Contains functions which manipulate file and path names.</p></div></div>
<div class="function"><h3 id="files-and-paths-base_file_name"><a href="#files-and-paths-base_file_name-idx">
function base_file_name
</a></h3>
<div class="description">
<p>
Returns the base name of the file without the directory or file suffix.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
base_file_name
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
base_file_name('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
'country_boundaries'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-file_exists"><a href="#files-and-paths-file_exists-idx">
function file_exists
</a></h3>
<div class="description">
<p>
Returns true if a file path exists.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
file_exists
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
file_exists('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-file_name"><a href="#files-and-paths-file_name-idx">
function file_name
</a></h3>
<div class="description">
<p>
Returns the name of a file (including the file extension), excluding the directory.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
file_name
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
file_name('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
'country_boundaries.shp'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-file_path"><a href="#files-and-paths-file_path-idx">
function file_path
</a></h3>
<div class="description">
<p>
Returns the directory component of a file path. This does not include the file name.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
file_path
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
file_path('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
'/home/qgis/data'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-file_size"><a href="#files-and-paths-file_size-idx">
function file_size
</a></h3>
<div class="description">
<p>
Returns the size (in bytes) of a file.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
file_size
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
file_size('/home/qgis/data/country_boundaries.geojson')
</code>
→
<code>
5674
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-file_suffix"><a href="#files-and-paths-file_suffix-idx">
function file_suffix
</a></h3>
<div class="description">
<p>
Returns the file suffix (extension) from a file path.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
file_suffix
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
file_suffix('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
'shp'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-is_directory"><a href="#files-and-paths-is_directory-idx">
function is_directory
</a></h3>
<div class="description">
<p>
Returns true if a path corresponds to a directory.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_directory
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_directory('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_directory('/home/qgis/data/')
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="files-and-paths-is_file"><a href="#files-and-paths-is_file-idx">
function is_file
</a></h3>
<div class="description">
<p>
Returns true if a path corresponds to a file.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_file
</span>
(
<span class="argument">
path
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
path
</td>
<td>
a file path
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_file('/home/qgis/data/country_boundaries.shp')
</code>
→
<code>
true
</code>
</li>
<li>
<code>
is_file('/home/qgis/data/')
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div id="form" class="group">function help for Form missing</div>
<div class="function"><h3 id="form-current_value"><a href="#form-current_value-idx">
function current_value
</a></h3>
<div class="description">
<p>
Returns the current, unsaved value of a field in the form or table row currently being edited. This will differ from the feature's actual attribute values for features which are currently being edited or have not yet been added to a layer.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
current_value
</span>
(
<span class="argument">
field_name
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
field_name
</td>
<td>
a field name in the current form or table row
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
current_value( 'FIELD_NAME' )
</code>
→
<code>
The current value of field 'FIELD_NAME'.
</code>
</li>
</ul>
</div>
</div></div>
<div id="fuzzy-matching" class="group"><h2><a href="#fuzzy-matching-idx">group fuzzy matching</a></h2>
<div class="description"><p>This group contains functions for fuzzy comparisons between values.</p></div></div>
<div class="function"><h3 id="fuzzy-matching-hamming_distance"><a href="#fuzzy-matching-hamming_distance-idx">
function hamming_distance
</a></h3>
<div class="description">
<p>
Returns the Hamming distance between two strings. This equates to the number of characters at corresponding positions within the input strings where the characters are different. The input strings must be the same length, and the comparison is case-sensitive.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
hamming_distance
</span>
(
<span class="argument">
string1
</span>
,
<span class="argument">
string2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string1
</td>
<td>
a string
</td>
</tr>
<tr>
<td class="argument">
string2
</td>
<td>
a string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
hamming_distance('abc','xec')
</code>
→
<code>
2
</code>
</li>
<li>
<code>
hamming_distance('abc','ABc')
</code>
→
<code>
2
</code>
</li>
<li>
<code>
hamming_distance(upper('abc'),upper('ABC'))
</code>
→
<code>
0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="fuzzy-matching-levenshtein"><a href="#fuzzy-matching-levenshtein-idx">
function levenshtein
</a></h3>
<div class="description">
<p>
Returns the Levenshtein edit distance between two strings. This equates to the minimum number of character edits (insertions, deletions or substitutions) required to change one string to another.
<br/>
The Levenshtein distance is a measure of the similarity between two strings. Smaller distances mean the strings are more similar, and larger distances indicate more different strings. The distance is case sensitive.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
levenshtein
</span>
(
<span class="argument">
string1
</span>
,
<span class="argument">
string2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string1
</td>
<td>
a string
</td>
</tr>
<tr>
<td class="argument">
string2
</td>
<td>
a string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
levenshtein('kittens','mitten')
</code>
→
<code>
2
</code>
</li>
<li>
<code>
levenshtein('Kitten','kitten')
</code>
→
<code>
1
</code>
</li>
<li>
<code>
levenshtein(upper('Kitten'),upper('kitten'))
</code>
→
<code>
0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="fuzzy-matching-longest_common_substring"><a href="#fuzzy-matching-longest_common_substring-idx">
function longest_common_substring
</a></h3>
<div class="description">
<p>
Returns the longest common substring between two strings. This substring is the longest string that is a substring of the two input strings. For example, the longest common substring of "ABABC" and "BABCA" is "ABC". The substring is case sensitive.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
longest_common_substring
</span>
(
<span class="argument">
string1
</span>
,
<span class="argument">
string2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string1
</td>
<td>
a string
</td>
</tr>
<tr>
<td class="argument">
string2
</td>
<td>
a string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
longest_common_substring('ABABC','BABCA')
</code>
→
<code>
'ABC'
</code>
</li>
<li>
<code>
longest_common_substring('abcDeF','abcdef')
</code>
→
<code>
'abc'
</code>
</li>
<li>
<code>
longest_common_substring(upper('abcDeF'),upper('abcdex'))
</code>
→
<code>
'ABCDE'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="fuzzy-matching-soundex"><a href="#fuzzy-matching-soundex-idx">
function soundex
</a></h3>
<div class="description">
<p>
Returns the Soundex representation of a string. Soundex is a phonetic matching algorithm, so strings with similar sounds should be represented by the same Soundex code.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
soundex
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
a string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
soundex('robert')
</code>
→
<code>
'R163'
</code>
</li>
<li>
<code>
soundex('rupert')
</code>
→
<code>
'R163'
</code>
</li>
<li>
<code>
soundex('rubin')
</code>
→
<code>
'R150'
</code>
</li>
</ul>
</div>
</div></div>
<div id="general" class="group"><h2><a href="#general-idx">group general</a></h2>
<div class="description"><p>This group contains general assorted functions.</p></div></div>
<div class="function"><h3 id="general-env"><a href="#general-env-idx">
function env
</a></h3>
<div class="description">
<p>
Gets an environment variable and returns its content as a string. If the variable is not found, `NULL` will be returned. This is handy to inject system specific configuration like drive letters or path prefixes. Definition of environment variables depends on the operating system, please check with your system administrator or the operating system documentation how this can be set.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
env
</span>
(
<span class="argument">
name
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
name
</td>
<td>
The name of the environment variable which should be retrieved.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
env( 'LANG' )
</code>
→
<code>
'en_US.UTF-8'
</code>
</li>
<li>
<code>
env( 'MY_OWN_PREFIX_VAR' )
</code>
→
<code>
'Z:'
</code>
</li>
<li>
<code>
env( 'I_DO_NOT_EXIST' )
</code>
→
<code>
NULL
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="general-eval"><a href="#general-eval-idx">
function eval
</a></h3>
<div class="description">
<p>
Evaluates an expression which is passed in a string. Useful to expand dynamic parameters passed as context variables or fields.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
eval
</span>
(
<span class="argument">
expression
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
expression
</td>
<td>
an expression string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
eval(''nice'')
</code>
→
<code>
'nice'
</code>
</li>
<li>
<code>
eval(@expression_var)
</code>
→
<code>
[whatever the result of evaluating @expression_var might be…]
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="general-is_layer_visible"><a href="#general-is_layer_visible-idx">
function is_layer_visible
</a></h3>
<div class="description">
<p>
Returns true if a specified layer is visible.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_layer_visible
</span>
(
<span class="argument">
layer
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
layer
</td>
<td>
a string, representing either a layer name or layer ID
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_layer_visible('baseraster')
</code>
→
<code>
True
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="general-layer_property"><a href="#general-layer_property-idx">
function layer_property
</a></h3>
<div class="description">
<p>
Returns a matching layer property or metadata value.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
layer_property
</span>
(
<span class="argument">
layer
</span>
,
<span class="argument">
property
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
layer
</td>
<td>
a string, representing either a layer name or layer ID
</td>
</tr>
<tr>
<td class="argument">
property
</td>
<td>
a string corresponding to the property to return. Valid options are:
<br/>
<ul>
<li>
name: layer name
</li>
<li>
id: layer ID
</li>
<li>
title: metadata title string
</li>
<li>
abstract: metadata abstract string
</li>
<li>
keywords: metadata keywords
</li>
<li>
data_url: metadata URL
</li>
<li>
attribution: metadata attribution string
</li>
<li>
attribution_url: metadata attribution URL
</li>
<li>
source: layer source
</li>
<li>
min_scale: minimum display scale for layer
</li>
<li>
max_scale: maximum display scale for layer
</li>
<li>
crs: layer CRS
</li>
<li>
crs_definition: layer CRS full definition
</li>
<li>
crs_description: layer CRS description
</li>
<li>
extent: layer extent (as a geometry object)
</li>
<li>
type: layer type, e.g., Vector or Raster
</li>
<li>
storage_type: storage format (vector layers only)
</li>
<li>
geometry_type: geometry type, e.g., Point (vector layers only)
</li>
<li>
feature_count: approximate feature count for layer (vector layers only)
</li>
<li>
path: File path to the layer data source. Only available for file based layers.
</li>
</ul>
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
layer_property('streets','title')
</code>
→
<code>
'Basemap Streets'
</code>
</li>
<li>
<code>
layer_property('airports','feature_count')
</code>
→
<code>
120
</code>
</li>
<li>
<code>
layer_property('landsat','crs')
</code>
→
<code>
'EPSG:4326'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="general-var"><a href="#general-var-idx">
function var
</a></h3>
<div class="description">
<p>
Returns the value stored within a specified variable.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
var
</span>
(
<span class="argument">
name
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
name
</td>
<td>
a variable name
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
var('qgis_version')
</code>
→
<code>
'2.12'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="general-with_variable"><a href="#general-with_variable-idx">
function with_variable
</a></h3>
<div class="description">
<p>
This function sets a variable for any expression code that will be provided as 3rd argument. This is only useful for complicated expressions, where the same calculated value needs to be used in different places.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
with_variable
</span>
(
<span class="argument">
name
</span>
,
<span class="argument">
value
</span>
,
<span class="argument">
expression
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
name
</td>
<td>
the name of the variable to set
</td>
</tr>
<tr>
<td class="argument">
value
</td>
<td>
the value to set
</td>
</tr>
<tr>
<td class="argument">
expression
</td>
<td>
the expression for which the variable will be available
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
with_variable('my_sum', 1 + 2 + 3, @my_sum * 2 + @my_sum * 5)
</code>
→
<code>
42
</code>
</li>
</ul>
</div>
</div></div>
<div id="geometrygroup" class="group"><h2><a href="#geometrygroup-idx">group geometry</a></h2>
<div class="description"><p>This group contains functions that operate on geometry objects e.g length, area.</p></div></div>
<div class="function"><h3 id="geometrygroup-dollar-area"><a href="#geometrygroup-dollar-area-idx">
function $area
</a></h3>
<div class="description">
<p>
Returns the area of the current feature. The area calculated by this function respects both the current project's ellipsoid setting and area unit settings. For example, if an ellipsoid has been set for the project then the calculated area will be ellipsoidal, and if no ellipsoid is set then the calculated area will be planimetric.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$area
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$area
</code>
→
<code>
42
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-geometry"><a href="#geometrygroup-dollar-geometry-idx">
function $geometry
</a></h3>
<div class="description">
<p>
Returns the geometry of the current feature. Can be used for processing with other functions.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$geometry
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geomToWKT( $geometry )
</code>
→
<code>
POINT(6 50)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-length"><a href="#geometrygroup-dollar-length-idx">
function $length
</a></h3>
<div class="description">
<p>
Returns the length of a linestring. If you need the length of a border of a polygon, use $perimeter instead. The length calculated by this function respects both the current project's ellipsoid setting and distance unit settings. For example, if an ellipsoid has been set for the project then the calculated length will be ellipsoidal, and if no ellipsoid is set then the calculated length will be planimetric.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$length
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$length
</code>
→
<code>
42.4711
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-perimeter"><a href="#geometrygroup-dollar-perimeter-idx">
function $perimeter
</a></h3>
<div class="description">
<p>
Returns the perimeter length of the current feature. The perimeter calculated by this function respects both the current project's ellipsoid setting and distance unit settings. For example, if an ellipsoid has been set for the project then the calculated perimeter will be ellipsoidal, and if no ellipsoid is set then the calculated perimeter will be planimetric.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$perimeter
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$perimeter
</code>
→
<code>
42
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-x"><a href="#geometrygroup-dollar-x-idx">
function $x
</a></h3>
<div class="description">
<p>
Returns the x coordinate of the current feature.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$x
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$x
</code>
→
<code>
42
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-x_at"><a href="#geometrygroup-dollar-x_at-idx">
function $x_at
</a></h3>
<div class="description">
<p>
Retrieves a x coordinate of the current feature's geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$x_at
</span>
(
<span class="argument">
i
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
i
</td>
<td>
index of point of a line (indices start at 0; negative values apply from the last index, starting at -1)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$x_at(1)
</code>
→
<code>
5
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-y"><a href="#geometrygroup-dollar-y-idx">
function $y
</a></h3>
<div class="description">
<p>
Returns the y coordinate of the current feature.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$y
</span>
</code>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$y
</code>
→
<code>
42
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-dollar-y_at"><a href="#geometrygroup-dollar-y_at-idx">
function $y_at
</a></h3>
<div class="description">
<p>
Retrieves a y coordinate of the current feature's geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
$y_at
</span>
(
<span class="argument">
i
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
i
</td>
<td>
index of point of a line (indices start at 0; negative values apply from the last index, starting at -1)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
$y_at(1)
</code>
→
<code>
2
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-angle_at_vertex"><a href="#geometrygroup-angle_at_vertex-idx">
function angle_at_vertex
</a></h3>
<div class="description">
<p>
Returns the bisector angle (average angle) to the geometry for a specified vertex on a linestring geometry. Angles are in degrees clockwise from north.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
angle_at_vertex
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
vertex
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring geometry
</td>
</tr>
<tr>
<td class="argument">
vertex
</td>
<td>
vertex index, starting from 0; if the value is negative, the selected vertex index will be its total count minus the absolute value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
angle_at_vertex(geometry:=geom_from_wkt('LineString(0 0, 10 0, 10 10)'),vertex:=1)
</code>
→
<code>
45.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-area"><a href="#geometrygroup-area-idx">
function area
</a></h3>
<div class="description">
<p>
Returns the area of a geometry polygon object. Calculations are always planimetric in the Spatial Reference System (SRS) of this geometry, and the units of the returned area will match the units for the SRS. This differs from the calculations performed by the $area function, which will perform ellipsoidal calculations based on the project's ellipsoid and area unit settings.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
area
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
polygon geometry object
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
area(geom_from_wkt('POLYGON((0 0, 4 0, 4 2, 0 2, 0 0))'))
</code>
→
<code>
8.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-azimuth"><a href="#geometrygroup-azimuth-idx">
function azimuth
</a></h3>
<div class="description">
<p>
Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on point_a to point_b.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
azimuth
</span>
(
<span class="argument">
point_a
</span>
,
<span class="argument">
point_b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point_a
</td>
<td>
point geometry
</td>
</tr>
<tr>
<td class="argument">
point_b
</td>
<td>
point geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
degrees( azimuth( make_point(25, 45), make_point(75, 100) ) )
</code>
→
<code>
42.273689
</code>
</li>
<li>
<code>
degrees( azimuth( make_point(75, 100), make_point(25,45) ) )
</code>
→
<code>
222.273689
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-boundary"><a href="#geometrygroup-boundary-idx">
function boundary
</a></h3>
<div class="description">
<p>
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry). For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon. Some geometry types do not have a defined boundary, e.g., points or geometry collections, and will return null.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
boundary
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(boundary(geom_from_wkt('Polygon((1 1, 0 0, -1 1, 1 1))')))
</code>
→
<code>
'LineString(1 1,0 0,-1 1,1 1)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-bounds"><a href="#geometrygroup-bounds-idx">
function bounds
</a></h3>
<div class="description">
<p>
Returns a geometry which represents the bounding box of an input geometry. Calculations are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
bounds
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
bounds($geometry)
</code>
→
<code>
bounding box of $geometry
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-bounds_height"><a href="#geometrygroup-bounds_height-idx">
function bounds_height
</a></h3>
<div class="description">
<p>
Returns the height of the bounding box of a geometry. Calculations are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
bounds_height
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
bounds_height($geometry)
</code>
→
<code>
height of bounding box of $geometry
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-bounds_width"><a href="#geometrygroup-bounds_width-idx">
function bounds_width
</a></h3>
<div class="description">
<p>
Returns the width of the bounding box of a geometry. Calculations are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
bounds_width
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
bounds_width($geometry)
</code>
→
<code>
width of bounding box of $geometry
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-buffer"><a href="#geometrygroup-buffer-idx">
function buffer
</a></h3>
<div class="description">
<p>
Returns a geometry that represents all points whose distance from this geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
buffer
</span>
(
<span class="argument">
geom
</span>
,
<span class="argument">
distance
</span>
[,
<span class="argument">
segments=8
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
distance
</td>
<td>
buffer distance in layer units
</td>
</tr>
<tr>
<td class="argument">
segments
</td>
<td>
number of segments to use to represent a quarter circle when a round join style is used. A larger number results in a smoother buffer with more nodes.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
buffer($geometry, 10.5)
</code>
→
<code>
polygon of $geometry buffered by 10.5 units
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-buffer_by_m"><a href="#geometrygroup-buffer_by_m-idx">
function buffer_by_m
</a></h3>
<div class="description">
<p>
Creates a buffer along a line geometry where the buffer diameter varies according to the m-values at the line vertices.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
buffer_by_m
</span>
(
<span class="argument">
geometry
</span>
[,
<span class="argument">
segments=8
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
input geometry. Must be a (multi)line geometry with m values.
</td>
</tr>
<tr>
<td class="argument">
segments
</td>
<td>
number of segments to approximate quarter-circle curves in the buffer.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
buffer_by_m(geometry:=geom_from_wkt('LINESTRINGM(1 2 0.5, 4 2 0.2)'),segments:=8)
</code>
→
<code>
A variable width buffer starting with a diameter of 0.5 and ending with a diameter of 0.2 along the linestring geometry.
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-centroid"><a href="#geometrygroup-centroid-idx">
function centroid
</a></h3>
<div class="description">
<p>
Returns the geometric center of a geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
centroid
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
centroid($geometry)
</code>
→
<code>
a point geometry
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-closest_point"><a href="#geometrygroup-closest_point-idx">
function closest_point
</a></h3>
<div class="description">
<p>
Returns the point on geometry1 that is closest to geometry2.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
closest_point
</span>
(
<span class="argument">
geometry1
</span>
,
<span class="argument">
geometry2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry1
</td>
<td>
geometry to find closest point on
</td>
</tr>
<tr>
<td class="argument">
geometry2
</td>
<td>
geometry to find closest point to
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(closest_point(geom_from_wkt('LINESTRING (20 80, 98 190, 110 180, 50 75 )'),geom_from_wkt('POINT(100 100)')))
</code>
→
<code>
Point(73.0769 115.384)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-collect_geometries"><a href="#geometrygroup-collect_geometries-idx">
function collect_geometries
</a></h3>
<div class="description">
<p>
Collects a set of geometries into a multi-part geometry object.
</p>
</div>
<h3 id="geometrygroup-collect_geometries"><a href="#geometrygroup-collect_geometries-idx">
List of arguments variant
</a></h3>
<div class="description">
Geometry parts are specified as separate arguments to the function.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
collect_geometries
</span>
(
<span class="argument">
geometry1
</span>
,
<span class="argument">
geometry2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(collect_geometries(make_point(1,2), make_point(3,4), make_point(5,6)))
</code>
→
<code>
'MultiPoint ((1 2),(3 4),(5 6))'
</code>
</li>
</ul>
</div>
<h3 id="geometrygroup-collect_geometries"><a href="#geometrygroup-collect_geometries-idx">
Array variant
</a></h3>
<div class="description">
Geometry parts are specified as an array of geometry parts.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
collect_geometries
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
array of geometry objects
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(collect_geometries(array(make_point(1,2), make_point(3,4), make_point(5,6))))
</code>
→
<code>
'MultiPoint ((1 2),(3 4),(5 6))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-combine"><a href="#geometrygroup-combine-idx">
function combine
</a></h3>
<div class="description">
<p>
Returns the combination of two geometries.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
combine
</span>
(
<span class="argument">
geometry1
</span>
,
<span class="argument">
geometry2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry1
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry2
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( combine( geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 2 1)' ) ) )
</code>
→
<code>
MULTILINESTRING((4 4, 2 1), (3 3, 4 4), (4 4, 5 5))
</code>
</li>
<li>
<code>
geom_to_wkt( combine( geom_from_wkt( 'LINESTRING(3 3, 4 4)' ), geom_from_wkt( 'LINESTRING(3 3, 6 6, 2 1)' ) ) )
</code>
→
<code>
LINESTRING(3 3, 4 4, 6 6, 2 1)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-contains"><a href="#geometrygroup-contains-idx">
function contains
</a></h3>
<div class="description">
<p>
Tests whether a geometry contains another. Returns true if and only if no points of geometry b lie in the exterior of geometry a, and at least one point of the interior of b lies in the interior of a.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
contains
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
contains( geom_from_wkt( 'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))' ), geom_from_wkt( 'POINT(0.5 0.5 )' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
contains( geom_from_wkt( 'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-convex_hull"><a href="#geometrygroup-convex_hull-idx">
function convex_hull
</a></h3>
<div class="description">
<p>
Returns the convex hull of a geometry. It represents the minimum convex geometry that encloses all geometries within the set.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
convex_hull
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( convex_hull( geom_from_wkt( 'LINESTRING(3 3, 4 4, 4 10)' ) ) )
</code>
→
<code>
POLYGON((3 3,4 10,4 4,3 3))
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-crosses"><a href="#geometrygroup-crosses-idx">
function crosses
</a></h3>
<div class="description">
<p>
Tests whether a geometry crosses another. Returns true if the supplied geometries have some, but not all, interior points in common.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
crosses
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
crosses( geom_from_wkt( 'LINESTRING(3 5, 4 4, 5 3)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
crosses( geom_from_wkt( 'POINT(4 5)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-difference"><a href="#geometrygroup-difference-idx">
function difference
</a></h3>
<div class="description">
<p>
Returns a geometry that represents that part of geometry_a that does not intersect with geometry_b.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
difference
</span>
(
<span class="argument">
geometry_a
</span>
,
<span class="argument">
geometry_b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry_a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry_b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( difference( geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4)' ) ) )
</code>
→
<code>
LINESTRING(4 4, 5 5)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-disjoint"><a href="#geometrygroup-disjoint-idx">
function disjoint
</a></h3>
<div class="description">
<p>
Tests whether geometries do not spatially intersect. Returns true if the geometries do not share any space together.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
disjoint
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
disjoint( geom_from_wkt( 'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0 ))' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
disjoint( geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ), geom_from_wkt( 'POINT(4 4)' ))
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-distance"><a href="#geometrygroup-distance-idx">
function distance
</a></h3>
<div class="description">
<p>
Returns the minimum distance (based on spatial ref) between two geometries in projected units.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
distance
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
distance( geom_from_wkt( 'POINT(4 4)' ), geom_from_wkt( 'POINT(4 8)' ) )
</code>
→
<code>
4
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-distance_to_vertex"><a href="#geometrygroup-distance_to_vertex-idx">
function distance_to_vertex
</a></h3>
<div class="description">
<p>
Returns the distance along the geometry to a specified vertex.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
distance_to_vertex
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
vertex
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring geometry
</td>
</tr>
<tr>
<td class="argument">
vertex
</td>
<td>
vertex index, starting from 0; if the value is negative, the selected vertex index will be its total count minus the absolute value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
distance_to_vertex(geometry:=geom_from_wkt('LineString(0 0, 10 0, 10 10)'),vertex:=1)
</code>
→
<code>
10.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-end_point"><a href="#geometrygroup-end_point-idx">
function end_point
</a></h3>
<div class="description">
<p>
Returns the last node from a geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
end_point
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
geometry object
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(end_point(geom_from_wkt('LINESTRING(4 0, 4 2, 0 2)')))
</code>
→
<code>
'Point (0 2)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-extend"><a href="#geometrygroup-extend-idx">
function extend
</a></h3>
<div class="description">
<p>
Extends the start and end of a linestring geometry by a specified amount. Lines are extended using the bearing of the first and last segment in the line. Distances are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
extend
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
start_distance
</span>
,
<span class="argument">
end_distance
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a (multi)linestring geometry
</td>
</tr>
<tr>
<td class="argument">
start_distance
</td>
<td>
distance to extend the start of the line
</td>
</tr>
<tr>
<td class="argument">
end_distance
</td>
<td>
distance to extend the end of the line.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(extend(geom_from_wkt('LineString(0 0, 1 0, 1 1)'),1,2))
</code>
→
<code>
LineString (-1 0, 1 0, 1 3)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-exterior_ring"><a href="#geometrygroup-exterior_ring-idx">
function exterior_ring
</a></h3>
<div class="description">
<p>
Returns a line string representing the exterior ring of a polygon geometry. If the geometry is not a polygon then the result will be null.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
exterior_ring
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a polygon geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(exterior_ring(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),( 0.1 0.1, 0.1 0.2, 0.2 0.2, 0.2, 0.1, 0.1 0.1))')))
</code>
→
<code>
'LineString (-1 -1, 4 0, 4 2, 0 2, -1 -1)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-extrude"><a href="#geometrygroup-extrude-idx">
function extrude
</a></h3>
<div class="description">
<p>
Returns an extruded version of the input (Multi-)Curve or (Multi-)Linestring geometry with an extension specified by x and y.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
extrude
</span>
(
<span class="argument">
geom
</span>
,
<span class="argument">
x
</span>
,
<span class="argument">
y
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a polygon geometry
</td>
</tr>
<tr>
<td class="argument">
x
</td>
<td>
x extension, numeric value
</td>
</tr>
<tr>
<td class="argument">
y
</td>
<td>
y extension, numeric value
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
extrude(geom_from_wkt('LineString(1 2, 3 2, 4 3)'), 1, 2)
</code>
→
<code>
Polygon ((1 2, 3 2, 4 3, 5 5, 4 4, 2 4, 1 2))
</code>
</li>
<li>
<code>
extrude(geom_from_wkt('MultiLineString((1 2, 3 2), (4 3, 8 3)'), 1, 2)
</code>
→
<code>
MultiPolygon (((1 2, 3 2, 4 4, 2 4, 1 2)),((4 3, 8 3, 9 5, 5 5, 4 3)))
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-flip_coordinates"><a href="#geometrygroup-flip_coordinates-idx">
function flip_coordinates
</a></h3>
<div class="description">
<p>
Returns a copy of the geometry with the x and y coordinates swapped. Useful for repairing geometries which have had their latitude and longitude values reversed.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
flip_coordinates
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(flip_coordinates(make_point(1, 2)))
</code>
→
<code>
Point (2 1)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-force_rhr"><a href="#geometrygroup-force_rhr-idx">
function force_rhr
</a></h3>
<div class="description">
<p>
Forces a geometry to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
force_rhr
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry. Any non-polygon geometries are returned unchanged.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(force_rhr(geometry:=geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))')))
</code>
→
<code>
Polygon ((-1 -1, 0 2, 4 2, 4 0, -1 -1))
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geom_from_gml"><a href="#geometrygroup-geom_from_gml-idx">
function geom_from_gml
</a></h3>
<div class="description">
<p>
Returns a geometry from a GML representation of geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geom_from_gml
</span>
(
<span class="argument">
gml
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
gml
</td>
<td>
GML representation of a geometry as a string
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_from_gml('&lt;gml:LineString srsName="EPSG:4326"&gt;&lt;gml:coordinates&gt;4,4 5,5 6,6&lt;/gml:coordinates&gt;&lt;/gml:LineString&gt;')
</code>
→
<code>
a line geometry object
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geom_from_wkb"><a href="#geometrygroup-geom_from_wkb-idx">
function geom_from_wkb
</a></h3>
<div class="description">
<p>
Returns a geometry created from a Well-Known Binary (WKB) representation.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geom_from_wkb
</span>
(
<span class="argument">
binary
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
binary
</td>
<td>
Well-Known Binary (WKB) representation of a geometry (as a binary blob)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_from_wkb( geom_to_wkb( make_point(4,5) ) )
</code>
→
<code>
a point geometry object
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geom_from_wkt"><a href="#geometrygroup-geom_from_wkt-idx">
function geom_from_wkt
</a></h3>
<div class="description">
<p>
Returns a geometry created from a Well-Known Text (WKT) representation.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geom_from_wkt
</span>
(
<span class="argument">
text
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
text
</td>
<td>
Well-Known Text (WKT) representation of a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_from_wkt( 'POINT(4 5)' )
</code>
→
<code>
a geometry object
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geom_to_wkb"><a href="#geometrygroup-geom_to_wkb-idx">
function geom_to_wkb
</a></h3>
<div class="description">
<p>
Returns the Well-Known Binary (WKB) representation of a geometry as a binary blob.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geom_to_wkb
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkb( $geometry )
</code>
→
<code>
binary blob containing a geometry object
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geom_to_wkt"><a href="#geometrygroup-geom_to_wkt-idx">
function geom_to_wkt
</a></h3>
<div class="description">
<p>
Returns the Well-Known Text (WKT) representation of the geometry without SRID metadata.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geom_to_wkt
</span>
(
<span class="argument">
geometry
</span>
[,
<span class="argument">
precision
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
precision
</td>
<td>
numeric precision
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( $geometry )
</code>
→
<code>
POINT(6 50)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geometry"><a href="#geometrygroup-geometry-idx">
function geometry
</a></h3>
<div class="description">
<p>
Returns a feature's geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geometry
</span>
(
<span class="argument">
feature
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
feature
</td>
<td>
a feature object
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( geometry( get_feature( layer, attributeField, value ) ) )
</code>
→
<code>
'POINT(6 50)'
</code>
</li>
<li>
<code>
intersects( $geometry, geometry( get_feature( layer, attributeField, value ) ) )
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-geometry_n"><a href="#geometrygroup-geometry_n-idx">
function geometry_n
</a></h3>
<div class="description">
<p>
Returns a specific geometry from a geometry collection, or null if the input geometry is not a collection.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
geometry_n
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
index
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
geometry collection
</td>
</tr>
<tr>
<td class="argument">
index
</td>
<td>
index of geometry to return, where 1 is the first geometry in the collection
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(geometry_n(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))'),3))
</code>
→
<code>
'Point (1 0)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-hausdorff_distance"><a href="#geometrygroup-hausdorff_distance-idx">
function hausdorff_distance
</a></h3>
<div class="description">
<p>
Returns the Hausdorff distance between two geometries. This is basically a measure of how similar or dissimilar 2 geometries are, with a lower distance indicating more similar geometries.
<br/>
The function can be executed with an optional densify fraction argument. If not specified, an approximation to the standard Hausdorff distance is used. This approximation is exact or close enough for a large subset of useful cases. Examples of these are:
<br/>
<br/>
<li>
computing distance between Linestrings that are roughly parallel to each other, and roughly equal in length. This occurs in matching linear networks.
</li>
<li>
Testing similarity of geometries.
</li>
<br/>
<br/>
If the default approximate provided by this method is insufficient, specify the optional densify fraction argument. Specifying this argument performs a segment densification before computing the discrete Hausdorff distance. The parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction. Decreasing the densify fraction parameter will make the distance returned approach the true Hausdorff distance for the geometries.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
hausdorff_distance
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
[,
<span class="argument">
densify_fraction
</span>
])
</code>
<br>
<br>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
densify_fraction
</td>
<td>
densify fraction amount
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
hausdorff_distance( geometry1:= geom_from_wkt('LINESTRING (0 0, 2 1)'),geometry2:=geom_from_wkt('LINESTRING (0 0, 2 0)'))
</code>
→
<code>
2
</code>
</li>
<li>
<code>
hausdorff_distance( geom_from_wkt('LINESTRING (130 0, 0 0, 0 150)'),geom_from_wkt('LINESTRING (10 10, 10 150, 130 10)'))
</code>
→
<code>
14.142135623
</code>
</li>
<li>
<code>
hausdorff_distance( geom_from_wkt('LINESTRING (130 0, 0 0, 0 150)'),geom_from_wkt('LINESTRING (10 10, 10 150, 130 10)'),0.5)
</code>
→
<code>
70.0
</code>
</li>
</ul>
</div>
</br>
</br>
</div></div>
<div class="function"><h3 id="geometrygroup-inclination"><a href="#geometrygroup-inclination-idx">
function inclination
</a></h3>
<div class="description">
<p>
Returns the inclination measured from the zenith (0) to the nadir (180) on point_a to point_b.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
inclination
</span>
(
<span class="argument">
point_a
</span>
,
<span class="argument">
point_b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point_a
</td>
<td>
point geometry
</td>
</tr>
<tr>
<td class="argument">
point_b
</td>
<td>
point geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
inclination( make_point( 5, 10, 0 ), make_point( 5, 10, 5 ) )
</code>
→
<code>
0.0
</code>
</li>
<li>
<code>
inclination( make_point( 5, 10, 0 ), make_point( 5, 10, 0 ) )
</code>
→
<code>
90.0
</code>
</li>
<li>
<code>
inclination( make_point( 5, 10, 0 ), make_point( 50, 100, 0 ) )
</code>
→
<code>
90.0
</code>
</li>
<li>
<code>
inclination( make_point( 5, 10, 0 ), make_point( 5, 10, -5 ) )
</code>
→
<code>
180.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-interior_ring_n"><a href="#geometrygroup-interior_ring_n-idx">
function interior_ring_n
</a></h3>
<div class="description">
<p>
Returns a specific interior ring from a polygon geometry, or null if the geometry is not a polygon.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
interior_ring_n
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
index
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
polygon geometry
</td>
</tr>
<tr>
<td class="argument">
index
</td>
<td>
index of interior to return, where 1 is the first interior ring
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(interior_ring_n(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-1 -1, 4 0, 4 2, 0 2, -1 -1))'),1))
</code>
→
<code>
'LineString (-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-intersection"><a href="#geometrygroup-intersection-idx">
function intersection
</a></h3>
<div class="description">
<p>
Returns a geometry that represents the shared portion of two geometries.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
intersection
</span>
(
<span class="argument">
geometry1
</span>
,
<span class="argument">
geometry2
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry1
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry2
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( intersection( geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4)' ) ) )
</code>
→
<code>
LINESTRING(3 3, 4 4)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-intersects"><a href="#geometrygroup-intersects-idx">
function intersects
</a></h3>
<div class="description">
<p>
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
intersects
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
intersects( geom_from_wkt( 'POINT(4 4)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
intersects( geom_from_wkt( 'POINT(4 5)' ), geom_from_wkt( 'POINT(5 5)' ) )
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-intersects_bbox"><a href="#geometrygroup-intersects_bbox-idx">
function intersects_bbox
</a></h3>
<div class="description">
<p>
Tests whether a geometry's bounding box overlaps another geometry's bounding box. Returns true if the geometries spatially intersect the bounding box defined and false if they do not.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
intersects_bbox
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
intersects_bbox( geom_from_wkt( 'POINT(4 5)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
intersects_bbox( geom_from_wkt( 'POINT(6 5)' ), geom_from_wkt( 'POLYGON((3 3, 4 4, 5 5, 3 3))' ) )
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-is_closed"><a href="#geometrygroup-is_closed-idx">
function is_closed
</a></h3>
<div class="description">
<p>
Returns true if a line string is closed (start and end points are coincident), or false if a line string is not closed. If the geometry is not a line string then the result will be null.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_closed
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a line string geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_closed(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)'))
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_closed(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2, 0 0)'))
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-is_empty"><a href="#geometrygroup-is_empty-idx">
function is_empty
</a></h3>
<div class="description">
<p>
Returns true if a geometry is empty (without coordinates), false if the geometry is not empty and NULL if there is no geometry. See also `is_empty_or_null`.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_empty
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_empty(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)'))
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_empty(geom_from_wkt('LINESTRING EMPTY'))
</code>
→
<code>
true
</code>
</li>
<li>
<code>
is_empty(geom_from_wkt('POINT(7 4)'))
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_empty(geom_from_wkt('POINT EMPTY'))
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-is_empty_or_null"><a href="#geometrygroup-is_empty_or_null-idx">
function is_empty_or_null
</a></h3>
<div class="description">
<p>
Returns true if a geometry is NULL or empty (without coordinates) or false otherwise. This function is like the expression '$geometry IS NULL or is_empty($geometry)'
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_empty_or_null
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_empty_or_null(NULL)
</code>
→
<code>
true
</code>
</li>
<li>
<code>
is_empty_or_null(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)'))
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_empty_or_null(geom_from_wkt('LINESTRING EMPTY'))
</code>
→
<code>
true
</code>
</li>
<li>
<code>
is_empty_or_null(geom_from_wkt('POINT(7 4)'))
</code>
→
<code>
false
</code>
</li>
<li>
<code>
is_empty_or_null(geom_from_wkt('POINT EMPTY'))
</code>
→
<code>
true
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-is_valid"><a href="#geometrygroup-is_valid-idx">
function is_valid
</a></h3>
<div class="description">
<p>
Returns true if a geometry is valid; if it is well-formed in 2D according to the OGC rules.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
is_valid
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
is_valid(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2, 0 0)'))
</code>
→
<code>
true
</code>
</li>
<li>
<code>
is_valid(geom_from_wkt('LINESTRING(0 0)'))
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-length"><a href="#geometrygroup-length-idx">
function length
</a></h3>
<div class="description">
<p>
Returns the number of characters in a string or the length of a geometry linestring.
</p>
</div>
<h3 id="geometrygroup-length"><a href="#geometrygroup-length-idx">
String variant
</a></h3>
<div class="description">
Returns the number of characters in a string.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
length
</span>
(
<span class="argument">
string
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
string
</td>
<td>
string to count length of
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
length('hello')
</code>
→
<code>
5
</code>
</li>
</ul>
</div>
<h3 id="geometrygroup-length"><a href="#geometrygroup-length-idx">
Geometry variant
</a></h3>
<div class="description">
Calculate the length of a geometry line object. Calculations are always planimetric in the Spatial Reference System (SRS) of this geometry, and the units of the returned length will match the units for the SRS. This differs from the calculations performed by the $length function, which will perform ellipsoidal calculations based on the project's ellipsoid and distance unit settings.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
length
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
line geometry object
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
length(geom_from_wkt('LINESTRING(0 0, 4 0)'))
</code>
→
<code>
4.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-line_interpolate_angle"><a href="#geometrygroup-line_interpolate_angle-idx">
function line_interpolate_angle
</a></h3>
<div class="description">
<p>
Returns the angle parallel to the geometry at a specified distance along a linestring geometry. Angles are in degrees clockwise from north.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
line_interpolate_angle
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
distance
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring geometry
</td>
</tr>
<tr>
<td class="argument">
distance
</td>
<td>
distance along line to interpolate angle at
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
line_interpolate_angle(geometry:=geom_from_wkt('LineString(0 0, 10 0)'),distance:=5)
</code>
→
<code>
90.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-line_interpolate_point"><a href="#geometrygroup-line_interpolate_point-idx">
function line_interpolate_point
</a></h3>
<div class="description">
<p>
Returns the point interpolated by a specified distance along a linestring geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
line_interpolate_point
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
distance
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring geometry
</td>
</tr>
<tr>
<td class="argument">
distance
</td>
<td>
distance along line to interpolate
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(line_interpolate_point(geometry:=geom_from_wkt('LineString(0 0, 10 0)'),distance:=5))
</code>
→
<code>
'Point (5 0)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-line_locate_point"><a href="#geometrygroup-line_locate_point-idx">
function line_locate_point
</a></h3>
<div class="description">
<p>
Returns the distance along a linestring corresponding to the closest position the linestring comes to a specified point geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
line_locate_point
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
point
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring geometry
</td>
</tr>
<tr>
<td class="argument">
point
</td>
<td>
point geometry to locate closest position on linestring to
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
line_locate_point(geometry:=geom_from_wkt('LineString(0 0, 10 0)'),point:=geom_from_wkt('Point(5 0)'))
</code>
→
<code>
5.0
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-line_merge"><a href="#geometrygroup-line_merge-idx">
function line_merge
</a></h3>
<div class="description">
<p>
Returns a LineString or MultiLineString geometry, where any connected LineStrings from the input geometry have been merged into a single linestring. This function will return null if passed a geometry which is not a LineString/MultiLineString.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
line_merge
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a LineString/MultiLineString geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(line_merge(geom_from_wkt('MULTILINESTRING((0 0, 1 1),(1 1, 2 2))')))
</code>
→
<code>
'LineString(0 0,1 1,2 2)'
</code>
</li>
<li>
<code>
geom_to_wkt(line_merge(geom_from_wkt('MULTILINESTRING((0 0, 1 1),(11 1, 21 2))')))
</code>
→
<code>
'MultiLineString((0 0, 1 1),(11 1, 21 2)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-line_substring"><a href="#geometrygroup-line_substring-idx">
function line_substring
</a></h3>
<div class="description">
<p>
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.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
line_substring
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
start_distance
</span>
,
<span class="argument">
end_distance
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a linestring or curve geometry
</td>
</tr>
<tr>
<td class="argument">
start_distance
</td>
<td>
distance to start of substring
</td>
</tr>
<tr>
<td class="argument">
end_distance
</td>
<td>
distance to end of substring
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(line_substring(geometry:=geom_from_wkt('LineString(0 0, 10 0)'),start_distance:=2,end_distance=6))
</code>
→
<code>
'LineString (2 0,6 0)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-m"><a href="#geometrygroup-m-idx">
function m
</a></h3>
<div class="description">
<p>
Returns the m value of a point geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
m
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a point geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
m( geom_from_wkt( 'POINTM(2 5 4)' ) )
</code>
→
<code>
4
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_circle"><a href="#geometrygroup-make_circle-idx">
function make_circle
</a></h3>
<div class="description">
<p>
Creates a circular polygon.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_circle
</span>
(
<span class="argument">
center
</span>
,
<span class="argument">
radius
</span>
[,
<span class="argument">
segment=36
</span>
]…)
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
center
</td>
<td>
center point of the circle
</td>
</tr>
<tr>
<td class="argument">
radius
</td>
<td>
radius of the circle
</td>
</tr>
<tr>
<td class="argument">
segment
</td>
<td>
optional argument for polygon segmentation. By default this value is 36
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_circle(make_point(10,10), 5, 4))
</code>
→
<code>
'Polygon ((10 15, 15 10, 10 5, 5 10, 10 15))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_circle(make_point(10,10,5), 5, 4))
</code>
→
<code>
'PolygonZ ((10 15 5, 15 10 5, 10 5 5, 5 10 5, 10 15 5))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_circle(make_point(10,10,5,30), 5, 4))
</code>
→
<code>
'PolygonZM ((10 15 5 30, 15 10 5 30, 10 5 5 30, 5 10 5 30, 10 15 5 30))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_ellipse"><a href="#geometrygroup-make_ellipse-idx">
function make_ellipse
</a></h3>
<div class="description">
<p>
Creates an elliptical polygon.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_ellipse
</span>
(
<span class="argument">
center
</span>
,
<span class="argument">
semi_major_axis
</span>
,
<span class="argument">
semi_minor_axis
</span>
,
<span class="argument">
azimuth
</span>
[,
<span class="argument">
segment=36
</span>
]…)
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
center
</td>
<td>
center point of the ellipse
</td>
</tr>
<tr>
<td class="argument">
semi_major_axis
</td>
<td>
semi-major axis of the ellipse
</td>
</tr>
<tr>
<td class="argument">
semi_minor_axis
</td>
<td>
semi-minor axis of the ellipse
</td>
</tr>
<tr>
<td class="argument">
azimuth
</td>
<td>
orientation of the ellipse
</td>
</tr>
<tr>
<td class="argument">
segment
</td>
<td>
optional argument for polygon segmentation. By default this value is 36
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_ellipse(make_point(10,10), 5, 2, 90, 4))
</code>
→
<code>
'Polygon ((15 10, 10 8, 5 10, 10 12, 15 10))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_ellipse(make_point(10,10,5), 5, 2, 90, 4))
</code>
→
<code>
'PolygonZ ((15 10 5, 10 8 5, 5 10 5, 10 12 5, 15 10 5))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_ellipse(make_point(10,10,5,30), 5, 2, 90, 4))
</code>
→
<code>
'PolygonZM ((15 10 5 30, 10 8 5 30, 5 10 5 30, 10 12 5 30, 15 10 5 30))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_line"><a href="#geometrygroup-make_line-idx">
function make_line
</a></h3>
<div class="description">
<p>
Creates a line geometry from a series of point geometries.
</p>
</div>
<h3 id="geometrygroup-make_line"><a href="#geometrygroup-make_line-idx">
List of arguments variant
</a></h3>
<div class="description">
Line vertices are specified as separate arguments to the function.
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_line
</span>
(
<span class="argument">
point1
</span>
,
<span class="argument">
point2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point
</td>
<td>
a point geometry (or array of points)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_line(make_point(2,4),make_point(3,5)))
</code>
→
<code>
'LineString (2 4, 3 5)'
</code>
</li>
<li>
<code>
geom_to_wkt(make_line(make_point(2,4),make_point(3,5),make_point(9,7)))
</code>
→
<code>
'LineString (2 4, 3 5, 9 7)'
</code>
</li>
</ul>
</div>
<h3 id="geometrygroup-make_line"><a href="#geometrygroup-make_line-idx">
Array variant
</a></h3>
<div class="description">
Line vertices are specified as an array of points.
</div>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_line
</span>
(
<span class="argument">
array
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
array
</td>
<td>
array of points
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_line(array(make_point(2,4),make_point(3,5),make_point(9,7))))
</code>
→
<code>
'LineString (2 4, 3 5, 9 7)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_point"><a href="#geometrygroup-make_point-idx">
function make_point
</a></h3>
<div class="description">
<p>
Creates a point geometry from an x and y (and optional z and m) value.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_point
</span>
(
<span class="argument">
x
</span>
,
<span class="argument">
y
</span>
[,
<span class="argument">
z
</span>
][,
<span class="argument">
m
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
x
</td>
<td>
x coordinate of point
</td>
</tr>
<tr>
<td class="argument">
y
</td>
<td>
y coordinate of point
</td>
</tr>
<tr>
<td class="argument">
z
</td>
<td>
optional z coordinate of point
</td>
</tr>
<tr>
<td class="argument">
m
</td>
<td>
optional m value of point
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_point(2,4))
</code>
→
<code>
'Point (2 4)'
</code>
</li>
<li>
<code>
geom_to_wkt(make_point(2,4,6))
</code>
→
<code>
'PointZ (2 4 6)'
</code>
</li>
<li>
<code>
geom_to_wkt(make_point(2,4,6,8))
</code>
→
<code>
'PointZM (2 4 6 8)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_point_m"><a href="#geometrygroup-make_point_m-idx">
function make_point_m
</a></h3>
<div class="description">
<p>
Creates a point geometry from an x, y coordinate and m value.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_point_m
</span>
(
<span class="argument">
x
</span>
,
<span class="argument">
y
</span>
,
<span class="argument">
m
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
x
</td>
<td>
x coordinate of point
</td>
</tr>
<tr>
<td class="argument">
y
</td>
<td>
y coordinate of point
</td>
</tr>
<tr>
<td class="argument">
m
</td>
<td>
m value of point
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_point_m(2,4,6))
</code>
→
<code>
'PointM (2 4 6)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_polygon"><a href="#geometrygroup-make_polygon-idx">
function make_polygon
</a></h3>
<div class="description">
<p>
Creates a polygon geometry from an outer ring and optional series of inner ring geometries.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_polygon
</span>
(
<span class="argument">
outerRing
</span>
[,
<span class="argument">
innerRing1
</span>
][,
<span class="argument">
innerRing2
</span>
]…)
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
outerRing
</td>
<td>
closed line geometry for polygon's outer ring
</td>
</tr>
<tr>
<td class="argument">
innerRing
</td>
<td>
optional closed line geometry for inner ring
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_polygon(geom_from_wkt('LINESTRING( 0 0, 0 1, 1 1, 1 0, 0 0 )')))
</code>
→
<code>
'Polygon ((0 0, 0 1, 1 1, 1 0, 0 0))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_polygon(geom_from_wkt('LINESTRING( 0 0, 0 1, 1 1, 1 0, 0 0 )'),geom_from_wkt('LINESTRING( 0.1 0.1, 0.1 0.2, 0.2 0.2, 0.2 0.1, 0.1 0.1 )'),geom_from_wkt('LINESTRING( 0.8 0.8, 0.8 0.9, 0.9 0.9, 0.9 0.8, 0.8 0.8 )')))
</code>
→
<code>
'Polygon ((0 0, 0 1, 1 1, 1 0, 0 0),(0.1 0.1, 0.1 0.2, 0.2 0.2, 0.2 0.1, 0.1 0.1),(0.8 0.8, 0.8 0.9, 0.9 0.9, 0.9 0.8, 0.8 0.8))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_rectangle_3points"><a href="#geometrygroup-make_rectangle_3points-idx">
function make_rectangle_3points
</a></h3>
<div class="description">
<p>
Creates a rectangle from 3 points.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_rectangle_3points
</span>
(
<span class="argument">
point1
</span>
,
<span class="argument">
point2
</span>
,
<span class="argument">
point3
</span>
[,
<span class="argument">
option=0
</span>
]…)
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point1
</td>
<td>
First point.
</td>
</tr>
<tr>
<td class="argument">
point2
</td>
<td>
Second point.
</td>
</tr>
<tr>
<td class="argument">
point3
</td>
<td>
Third point.
</td>
</tr>
<tr>
<td class="argument">
option
</td>
<td>
An optional argument to construct the rectangle. By default this value is 0. Value can be 0 (distance) or 1 (projected). Option distance: Second distance is equal to the distance between 2nd and 3rd point. Option projected: Second distance is equal to the distance of the perpendicular projection of the 3rd point on the segment or its extension.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_rectangle(make_point(0, 0), make_point(0,5), make_point(5, 5), 0)))
</code>
→
<code>
'Polygon ((0 0, 0 5, 5 5, 5 0, 0 0))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_rectangle(make_point(0, 0), make_point(0,5), make_point(5, 3), 1)))
</code>
→
<code>
'Polygon ((0 0, 0 5, 5 5, 5 0, 0 0))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_regular_polygon"><a href="#geometrygroup-make_regular_polygon-idx">
function make_regular_polygon
</a></h3>
<div class="description">
<p>
Creates a regular polygon.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_regular_polygon
</span>
(
<span class="argument">
center
</span>
,
<span class="argument">
radius
</span>
,
<span class="argument">
number_sides
</span>
[,
<span class="argument">
circle=0
</span>
]…)
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
center
</td>
<td>
center of the regular polygon
</td>
</tr>
<tr>
<td class="argument">
radius
</td>
<td>
second point. The first if the regular polygon is inscribed. The midpoint of the first side if the regular polygon is circumscribed.
</td>
</tr>
<tr>
<td class="argument">
number_sides
</td>
<td>
Number of sides/edges of the regular polygon
</td>
</tr>
<tr>
<td class="argument">
circle
</td>
<td>
Optional argument to construct the regular polygon. By default this value is 0. Value can be 0 (inscribed) or 1 (circumscribed)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_regular_polygon(make_point(0,0), make_point(0,5), 5))
</code>
→
<code>
'Polygon ((0 5, 4.76 1.55, 2.94 -4.05, -2.94 -4.05, -4.76 1.55, 0 5))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_regular_polygon(make_point(0,0), project(make_point(0,0), 4.0451, radians(36)), 5))
</code>
→
<code>
'Polygon ((0 5, 4.76 1.55, 2.94 -4.05, -2.94 -4.05, -4.76 1.55, 0 5))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_square"><a href="#geometrygroup-make_square-idx">
function make_square
</a></h3>
<div class="description">
<p>
Creates a square from a diagonal.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_square
</span>
(
<span class="argument">
point1
</span>
,
<span class="argument">
point2
</span>
…)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point1
</td>
<td>
First point of the regular polygon
</td>
</tr>
<tr>
<td class="argument">
point2
</td>
<td>
Second point
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_square( make_point(0,0), make_point(5,5)))
</code>
→
<code>
'Polygon ((0 0, -0 5, 5 5, 5 0, 0 0))'
</code>
</li>
<li>
<code>
geom_to_wkt(make_square( make_point(5,0), make_point(5,5)))
</code>
→
<code>
'Polygon ((5 0, 2.5 2.5, 5 5, 7.5 2.5, 5 0))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-make_triangle"><a href="#geometrygroup-make_triangle-idx">
function make_triangle
</a></h3>
<div class="description">
<p>
Creates a triangle polygon.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
make_triangle
</span>
(
<span class="argument">
point 1
</span>
,
<span class="argument">
point 2
</span>
,
<span class="argument">
point 3
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
point 1
</td>
<td>
first point of the triangle
</td>
</tr>
<tr>
<td class="argument">
point 2
</td>
<td>
second point of the triangle
</td>
</tr>
<tr>
<td class="argument">
point 3
</td>
<td>
third point of the triangle
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(make_triangle(make_point(0,0), make_point(5,5), make_point(0,10)))
</code>
→
<code>
'Triangle ((0 0, 5 5, 0 10, 0 0))'
</code>
</li>
<li>
<code>
geom_to_wkt(boundary(make_triangle(make_point(0,0), make_point(5,5), make_point(0,10))))
</code>
→
<code>
'LineString (0 0, 5 5, 0 10, 0 0)'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-minimal_circle"><a href="#geometrygroup-minimal_circle-idx">
function minimal_circle
</a></h3>
<div class="description">
<p>
Returns the minimal enclosing circle of a geometry. It represents the minimum circle that encloses all geometries within the set.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
minimal_circle
</span>
(
<span class="argument">
geometry
</span>
[,
<span class="argument">
segment=36
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
segment
</td>
<td>
optional argument for polygon segmentation. By default this value is 36
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( minimal_circle( geom_from_wkt( 'LINESTRING(0 5, 0 -5, 2 1)' ), 4 ) )
</code>
→
<code>
Polygon ((0 5, 5 -0, -0 -5, -5 0, 0 5))
</code>
</li>
<li>
<code>
geom_to_wkt( minimal_circle( geom_from_wkt( 'MULTIPOINT(1 2, 3 4, 3 2)' ), 4 ) )
</code>
→
<code>
Polygon ((3 4, 3 2, 1 2, 1 4, 3 4))
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-nodes_to_points"><a href="#geometrygroup-nodes_to_points-idx">
function nodes_to_points
</a></h3>
<div class="description">
<p>
Returns a multipoint geometry consisting of every node in the input geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
nodes_to_points
</span>
(
<span class="argument">
geometry
</span>
[,
<span class="argument">
ignore_closing_nodes=false
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
geometry object
</td>
</tr>
<tr>
<td class="argument">
ignore_closing_nodes
</td>
<td>
optional argument specifying whether to include duplicate nodes which close lines or polygons rings. Defaults to false, set to true to avoid including these duplicate nodes in the output collection.
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt(nodes_to_points(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)')))
</code>
→
<code>
'MultiPoint ((0 0),(1 1),(2 2))'
</code>
</li>
<li>
<code>
geom_to_wkt(nodes_to_points(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))'),true))
</code>
→
<code>
'MultiPoint ((-1 -1),(4 0),(4 2),(0 2))'
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-num_geometries"><a href="#geometrygroup-num_geometries-idx">
function num_geometries
</a></h3>
<div class="description">
<p>
Returns the number of geometries in a geometry collection, or null if the input geometry is not a collection.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
num_geometries
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
geometry collection
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
num_geometries(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))'))
</code>
→
<code>
4
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-num_interior_rings"><a href="#geometrygroup-num_interior_rings-idx">
function num_interior_rings
</a></h3>
<div class="description">
<p>
Returns the number of interior rings in a polygon or geometry collection, or null if the input geometry is not a polygon or collection.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
num_interior_rings
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
input geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
num_interior_rings(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1))'))
</code>
→
<code>
1
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-num_points"><a href="#geometrygroup-num_points-idx">
function num_points
</a></h3>
<div class="description">
<p>
Returns the number of vertices in a geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
num_points
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
num_points($geometry)
</code>
→
<code>
number of vertices in $geometry
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-num_rings"><a href="#geometrygroup-num_rings-idx">
function num_rings
</a></h3>
<div class="description">
<p>
Returns the number of rings (including exterior rings) in a polygon or geometry collection, or null if the input geometry is not a polygon or collection.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
num_rings
</span>
(
<span class="argument">
geometry
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
input geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
num_rings(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1))'))
</code>
→
<code>
2
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-offset_curve"><a href="#geometrygroup-offset_curve-idx">
function offset_curve
</a></h3>
<div class="description">
<p>
Returns a geometry formed by offsetting a linestring geometry to the side. Distances are in the Spatial Reference System of this geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
offset_curve
</span>
(
<span class="argument">
geometry
</span>
,
<span class="argument">
distance
</span>
[,
<span class="argument">
segments=8
</span>
][,
<span class="argument">
join=1
</span>
][,
<span class="argument">
miter_limit=2.0
</span>
])
</code>
<br/>
<br/>
[ ] marks optional components
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry
</td>
<td>
a (multi)linestring geometry
</td>
</tr>
<tr>
<td class="argument">
distance
</td>
<td>
offset distance. Positive values will be buffered to the left of lines, negative values to the right
</td>
</tr>
<tr>
<td class="argument">
segments
</td>
<td>
number of segments to use to represent a quarter circle when a round join style is used. A larger number results in a smoother line with more nodes.
</td>
</tr>
<tr>
<td class="argument">
join
</td>
<td>
join style for corners, where 1 = round, 2 = miter and 3 = bevel
</td>
</tr>
<tr>
<td class="argument">
miter_limit
</td>
<td>
limit on the miter ratio used for very sharp corners (when using miter joins only)
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
offset_curve($geometry, 10.5)
</code>
→
<code>
line offset to the left by 10.5 units
</code>
</li>
<li>
<code>
offset_curve($geometry, -10.5)
</code>
→
<code>
line offset to the right by 10.5 units
</code>
</li>
<li>
<code>
offset_curve($geometry, 10.5, segments=16, join=1)
</code>
→
<code>
line offset to the left by 10.5 units, using more segments to result in a smoother curve
</code>
</li>
<li>
<code>
offset_curve($geometry, 10.5, join=3)
</code>
→
<code>
line offset to the left by 10.5 units, using a beveled join
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-order_parts"><a href="#geometrygroup-order_parts-idx">
function order_parts
</a></h3>
<div class="description">
<p>
Orders the parts of a MultiGeometry by a given criteria
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
order_parts
</span>
(
<span class="argument">
geom
</span>
,
<span class="argument">
orderby
</span>
,
<span class="argument">
ascending
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a multi-type geometry
</td>
</tr>
<tr>
<td class="argument">
orderby
</td>
<td>
an expression string defining the order criteria
</td>
</tr>
<tr>
<td class="argument">
ascending
</td>
<td>
boolean, True for ascending, False for descending
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
order_parts(geom_from_wkt('MultiPolygon (((1 1, 5 1, 5 5, 1 5, 1 1)),((1 1, 9 1, 9 9, 1 9, 1 1)))'), 'area($geometry)', False)
</code>
→
<code>
MultiPolygon (((1 1, 9 1, 9 9, 1 9, 1 1)),((1 1, 5 1, 5 5, 1 5, 1 1)))
</code>
</li>
<li>
<code>
order_parts(geom_from_wkt('LineString(1 2, 3 2, 4 3)'), '1', True)
</code>
→
<code>
LineString(1 2, 3 2, 4 3)
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-oriented_bbox"><a href="#geometrygroup-oriented_bbox-idx">
function oriented_bbox
</a></h3>
<div class="description">
<p>
Returns a geometry which represents the minimal oriented bounding box of an input geometry.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
oriented_bbox
</span>
(
<span class="argument">
geom
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geom
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
geom_to_wkt( oriented_bbox( geom_from_wkt( 'MULTIPOINT(1 2, 3 4, 3 2)' ) ) )
</code>
→
<code>
Polygon ((1 4, 1 2, 3 2, 3 4, 1 4))
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-overlaps"><a href="#geometrygroup-overlaps-idx">
function overlaps
</a></h3>
<div class="description">
<p>
Tests whether a geometry overlaps another. Returns true if the geometries share space, are of the same dimension, but are not completely contained by each other.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
overlaps
</span>
(
<span class="argument">
geometry a
</span>
,
<span class="argument">
geometry b
</span>
)
</code>
<h4>
Arguments
</h4>
<div class="arguments">
<table>
<tr>
<td class="argument">
geometry a
</td>
<td>
a geometry
</td>
</tr>
<tr>
<td class="argument">
geometry b
</td>
<td>
a geometry
</td>
</tr>
</table>
</div>
<h4>
Examples
</h4>
<div class="examples">
<ul>
<li>
<code>
overlaps( geom_from_wkt( 'LINESTRING(3 5, 4 4, 5 5, 5 3)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
true
</code>
</li>
<li>
<code>
overlaps( geom_from_wkt( 'LINESTRING(0 0, 1 1)' ), geom_from_wkt( 'LINESTRING(3 3, 4 4, 5 5)' ) )
</code>
→
<code>
false
</code>
</li>
</ul>
</div>
</div></div>
<div class="function"><h3 id="geometrygroup-perimeter"><a href="#geometrygroup-perimeter-idx">
function perimeter
</a></h3>
<div class="description">
<p>
Returns the perimeter of a geometry polygon object. Calculations are always planimetric in the Spatial Reference System (SRS) of this geometry, and the units of the returned perimeter will match the units for the SRS. This differs from the calculations performed by the $perimeter function, which will perform ellipsoidal calculations based on the project's ellipsoid and distance unit settings.
</p>
</div>
<h4>
Syntax
</h4>
<div class="syntax">
<code>
<span class="functionname">
perimeter
</span>
(
<span class="argument">
geometry
</span>