Questions tagged [qgis-expression]
refers to a kind of dialect QGIS uses to expand its features, primarily used to calculate fields, manipulate geometry or manage symbology.
140
questions
2
votes
1
answer
69
views
Using string output of custom function with rule-based symbology in QGIS
I want to use the following custom function in a ruled-based symbology of a layer to filter features by the names of visible layers within another layer group:
@qgsfunction(args='auto', group='Custom')...
3
votes
2
answers
142
views
Dealing with NULL when using aggregate function in QGIS Expression
How to deal with NULL in QGIS expressions when using aggregate functions such as union?
E.g.:
geom_to_wkt(union(make_point(1,4), make_point(1,2))) ----> 'MultiPoint ((1 4),(1 2))'
geom_to_wkt(...
1
vote
0
answers
28
views
Labels defined with QGIS Expression and custom function not rendering in QGIS
In QGIS 3.34.5 I have a vector layer in QGIS with a large amount of attributes.
I want to generate labels that only show relevant attributes. To do that, I define a PyQGIS function that takes a ...
5
votes
2
answers
104
views
Getting the name of the closest feature from two different layers with QGIS Expression
In the expression builder (QGIS 3.38) attached to the "Default value" setting of the Attribute Form, I'd like to assign (i.e. fill/update) an attribute of the entities of a "feature&...
0
votes
0
answers
20
views
Autofill(filter) layers for a batch buffer processing using expression builder belonging to a "Group" in layers panel
I have a grouped ~20 vector layers named as "GroupedLayers". I want to use expression builder to autofill the inputs to batch processing. Otherwise I have to manually add layers one by one.
...
0
votes
0
answers
23
views
QGIS Layout Template - Draw Coordinates Buffer
Is there a way to create a buffer (e.g. 2cm) to prevent the coordinates drawn around the edge of a map from overlapping with each other or other features in the layout? I have experimented with ...
2
votes
1
answer
35
views
Adding value from map layer to label in print layout with expression
I would like to add value from layer “X” field “Y” with ID “1” to the label in my print layout with expression.
I don’t want to use atlas generator because I want this to be 1 layout with all of the ...
4
votes
1
answer
101
views
Finding the nearest point with QGIS Field Calculator
I have to point layers:
Boreholes (with 100 features)
Trees (with 300 features)
The tree layer has three attributes:
I would like to find the closest tree (based on "Tree_ID") to each ...
0
votes
2
answers
74
views
Removing duplicates values from QGIS Attribute table
I have some fields with the same values after that I need to remove them. Some of the values are duplicates after I merged values from different layers and grouped them using the same ID number.
For ...
2
votes
0
answers
34
views
Explaining syntax of the to_date function in QGIS Expression
In QGIS 3.16 I have loaded a CSV file with the following format:
and joined it to a shapefile.
I am trying to build an expression within Symbology and have tried various ways, one of which:
"...
4
votes
2
answers
79
views
Calculating closest point referenced to centroid in QGIS
I have a QGIS project in which I work with a polygon layer ('POLIGONS_TEST') and a point layer ('PUNTS_TEST').
I use the following Geometry Generator expression on the 'POLIGONS_TEST' layer to draw a ...
2
votes
1
answer
33
views
QGIS CircularChart expression symbology
I was trying to recover some maps I did back in 2017 using QGIS 2.18.
The map was using Circular Charts, this is a part of a longer expression in the Geometry Generator:
CircularChart("NAirbnb&...
1
vote
0
answers
83
views
On a QGIS layout, is it possible to obtain a scalebar's zero coordinates?
I have several pages on a layout, each of them has a scale bar. These scale bars' widths aren't fixed, they vary on each page (they are set to "Fit segment width", as you can see on the ...
6
votes
1
answer
159
views
Selecting field values that are integers or decimals with QGIS expression
I am trying to select features using an expression in a single file. The file contains polylines (contours) set at an elevation.
I want to select all features that are decimal: 1.2, 1.4, 1.6, etc. ...
0
votes
0
answers
39
views
Difference or Union geometry generators using (sometimes) empty layers in QGIS
I have a geometry generator expression which does some clipping and merging such as the below which works fine when there are features in layers 2 and 3, when there are no features in layers 2 or 3 ...
1
vote
1
answer
33
views
Filter/selecting features in layer in qgis by grouping after one column and only taking the max value of each group
Lets say there is a layer like this in qgis
which can be copy pasted from this geojson:
{
"type": "FeatureCollection",
"name": "test",
"crs": { "...
0
votes
0
answers
24
views
Get associated roadway from sidewalk geometries in QGIS using OpenStreetMap data
I work with pedestrian network data from OpenStreetMap for cities where sidewalks have already been mapped as separate lines for all corresponding streets at least for parts of the city area (examples:...
2
votes
2
answers
84
views
Retrieving label boundaries within QGIS Layout maps
Some time ago, I created a custom Python expression function to retrieve the boundaries of manually placed labels in QGIS:
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
@...
5
votes
1
answer
179
views
Accessing layer properties for expression syntax in QGIS Modeler
Overview: In QGIS I want to create a conditional branch in the model designer so that I can pass images with 20m resolution through the 'Warp (reproject)' tool. Images that are already at 10m ...
3
votes
1
answer
80
views
Mid_point label placement using Geometry Generator in QGIS
I've tried to place a label at the start, end, and middle of my lines in QGIS using the Geometry Generator.
This post, place-label-along-line-near-start-and-end-of-line-in-qgis, got me the start and ...
1
vote
1
answer
46
views
QGIS: Modeler: conditional branch & case dependent input fail
I have this model attached here wich has the left side (osm1) where the points input are beeing buffered - bounding box and the osm_highway is beeing downloaded.
The left side (osm2) should be an ...
2
votes
1
answer
65
views
Sort overlay intersections by area of overlap
I am able to get list of attributes of overlapping geometries in QGIS . I want to sort by descending area of overlaps in the geometric .
Original Expression
array_to_string(overlay_intersects(
layer:='...
1
vote
1
answer
41
views
Expression to count related number of owners in parcel layer in QGIS
Scenario: In a polygon layer with construction details (f.e. road, construction site) and one table layer with parcel owner information. Both layers have a column with the parcel_id, because the ...
3
votes
1
answer
177
views
Why doesn't with_variable work in this QGIS expression?
I'm trying to make a filter inside an overlay_nearest function where I must relate an attribute from the current layer to the overlay layer.
I'm trying to use with_variable to store the outer layer ...
2
votes
2
answers
177
views
Using filter expressions in QGIS calculator with overlay_nearest
I have a layer 'Points' and a layer 'Lines'.
Both layers contain an 'ID' attribute, which relate (but it's an m x n relation)
I'm trying to get the point position "along" a line, and I can ...
4
votes
2
answers
116
views
Why QGIS expression display double at concave sections?
I am trying to display the vertices of a polygon with vertex number. In symbology, I have used the Marker line and font marker.
.
When the Line offset is -5 positive the text 'P7' is displayed far ...
4
votes
2
answers
488
views
QGIS: expression in attribute table between greater than and less than with different categories in one field
I am trying to create a field that shows the following different categories in the same field:
Variable = verschil bouwhoogte
"Verschil bouwhoogte" <3
"Verschil bouwhoogte" =>...
7
votes
2
answers
194
views
QGIS functions: aggregate and array_foreach not working for vertices
I have two layers as the whole project in EPSG:4326:
polygon layer of countries
linestring layer of routes
I want to concatenate the country names (those are stored in "name" attribute) ...
0
votes
1
answer
96
views
QGIS expression, format number to number of decimals [duplicate]
I am using QGIS to plan a cable layout. Knowing the resitance per metre in the cables, lenght of cables and the current draw of each site, I can calculate the voltage available at each site.
The ...
0
votes
0
answers
87
views
QGIS relation reference widget filter between child (point layer) and parent table (no geometry)
I have two PostGIS layers in QGIS 3.28, they are in a 1-N relation (association):
layer A (parent) without geometry (table)
layer B (child) with point geometry
Both A and B layers have the codsede ...
-1
votes
1
answer
203
views
Geometry by expression does not work after intersection [closed]
I would like to split a linelayer with points in QGIS. For that, i found this answer: Splitting line with point layer in QGIS
I have one point layer: QBW_Strukturgütekartierung
and one line layer: ...
4
votes
2
answers
241
views
How to count points in percentage that are within an extension defined by two pairs of coordinates
Starting from a points geometry layer, my goal is to count points in percentage that are within an extension defined by two pairs of coordinates corresponding to the corners:
The initial situation is ...
0
votes
1
answer
86
views
Excel CEILING function equivalent in QGIS
In Ms Excel the CEILING function allows you to round up in steps as below. I need to round up in quarters in a QGIS expression and I would like to avoid something messy involving dividing my number by ...
1
vote
0
answers
59
views
How to reference tables in a GeoPackage after changing layer name in QGIS?
While developing a Geodatabase with a lot of tables, reports etc. I decided to rename some layers in QGIS to help my client use the database.
Now all my expressions like get_feature() won't work ...
0
votes
0
answers
37
views
How to get crs_description from EPSG-Code?
I'm searching for an expression in QGIS to get the description of a CRS
Assume I have following table:
Area
EPSG
desc
A1
EPSG:31258
A2
EPSG:31255
Now I want to fill in the "CRS-Description&...
1
vote
0
answers
56
views
Linking Point input data with SAGA Upslope input in QGIS Modeler
I have a model set up with a point input. I need the point's x and y coordinate data to populate the x-value and y-value fields required as input for the SAGA upslope function.
I have tried various ...
3
votes
4
answers
275
views
Extracting 'hour' from 'time_stamp' with QGIS
I am trying to extract the hour from my time_stamp which is in the format dd/mm/yyyy 00:00:00 as a textstring.
I am using the expression hour("time_stamp") in the field calculator, but the ...
2
votes
1
answer
61
views
Create parrallel lines in symbology according to attributes
I have a vector layer as lineString geometry type.
This layer has 2 attributes:
true_side is the line spacing.
true_witdh is the total width to distribute lines
The number of parrallel lines is ...
3
votes
1
answer
78
views
Grouping sum by user provided field name in graphical modeler
I want to sum and group some percentages as a part of a model in order to check whether the percentages are exactly 100, or if there is a small rounding error.
When using the field calculator outside ...
7
votes
2
answers
709
views
Converting azimuth to bearing with QGIS expression
For example, an azimuth of "225°" to read "S 45° W." I think there's a plugin that can do this, but I want to use this as a label in QField while digitizing.
6
votes
1
answer
122
views
Drawing 10 nearest lines from each point connecting to the centroid of the 5 points nearest to each point with QGIS expression
Starting from a layer with point geometry, my goal is to do two calculations in one Geometry Generator expression.
First, for each point, I would like to calculate the centroid for the 5 points ...
1
vote
1
answer
81
views
Writing degrees Celsius in short hand ('c) in QGIS expression
There is a way to add something before the ' to indicate to QGIS that it is a string and not a column. In expression builder I simply want
"temperature" || ''C'
7
votes
1
answer
161
views
Use algorithm output as expression in QGIS modeler
I want to use the algorithm output within the input expression of another algorithm in the Graphical Modeler of QGIS 3.30.3.
Specifically, I want to create clusters of areas previously identified as ...
1
vote
1
answer
101
views
Connect touching lines by condition using expressions in QGIS
I have a polyline layer (Layer_A) in QGIS that represents entities (street crossings) that either consist of a single feature or are split into two or more features. The entities may also touch at ...
3
votes
1
answer
119
views
Extracting two closest points with matching ID and create line between both points in QGIS
In QGIS, a have point vector Layer_A with a unique ID field and point vector Layer_B with multiple points for each Layer_A ID. For each point on Layer_A I want I need to create a line that connects ...
1
vote
0
answers
97
views
Extract central part of automatically created perpendicular lines in QGIS
I have a set of lines (roadways) on layer A and a set of (mainly) parallel lines (sidewalks) on layer B. I want to create perpendicular lines at a given distance that extend from the layer A center ...
3
votes
1
answer
101
views
Counting points from layer at map extent with QGIS expression
I want to create an expression in the QGIS 3.28 dashboard layer that counts points on a specific point_layer and with a specific value that is displayed in the current map_extent view
aggregate(
...
4
votes
1
answer
207
views
Creating horizontal lines connecting points using QGIS Geometry generator
I am using the geometry generator to learn how to generate vectors using expressions. Currently, I have a point vector, and I would like to create horizontal lines (shown in red: manually drawn) ...
7
votes
1
answer
197
views
Auto incremental field filled with filtered by other field value in QGIS Attribute Form
From a point geometry layer with two categories "A" and "B", when I enter new points, I first choose the category of the "CATEG" field with a listbox, and then I use the ...
5
votes
1
answer
141
views
Distribute a function for QGIS
I have written an expression to use in the field calculator that is to be used by a number of other users. In Providing QGIS expression within a plugin I was told how to distribute an expression (or a ...