Questions tagged [qgsexpression]

class for parsing and evaluation of expressions in QGIS API

Filter by
Sorted by
Tagged with
3 votes
1 answer
67 views

Changing symbol by expression in QGIS [duplicate]

The same way we can define the color of symbols using expressions, do you know if we can change the symbol itself in QGIS 3.24? In my situation, I use a layer 'OPTIONS' to change values on the map, ...
user avatar
  • 119
1 vote
0 answers
12 views

Style rule based on qgsfunction not working in QGIS 3.22 #92

I'm using a QGIS style based on a function which returns the value of a layer variable passed through a pyqgis plugin : @qgsfunction(args="auto", group="toto") def color_trajecto(...
user avatar
  • 859
4 votes
1 answer
63 views

Creating new attribute field gained by areal intersection in QGIS

I am trying to make a new attribute field which will differentiate points, vector layer, which lie inside and outside of a polygon layer. I tried like this: CASE WHEN '...
user avatar
2 votes
1 answer
45 views

Getting line length of geometry of parent feature as default value in child feature in QGIS

I have: a parent line-layer 'MyParentLineLayer' (referenced layer) with a field "parent_uuid" (referenced field). a child geometryless-layer 'MyChildLayer' (referencing layer) with a field &...
user avatar
1 vote
0 answers
26 views

Increasing the smoothness of a wave

I wrote a Geometry Generator expression to create a sine wave in the canvas (don't ask, just having fun): with_variable( 'points', map( 'point_middle_left', make_point(x(@...
user avatar
  • 8,421
3 votes
0 answers
136 views

case statement two string fields interacting

I have situation where the values from two fields (both strings) interact to create the value of a third (also a string). This is from a simple flowchart. I've tried using the CASE statement but I can'...
user avatar
1 vote
0 answers
55 views

Match label color to polygon color

I have a polygon layer in which I'm labelling each polygon on the map. I am trying to figure out how to make the label colour match that of the underlying polygon (with a white buffer around the label ...
user avatar
  • 869
4 votes
1 answer
52 views

Exctract one record from duplicates values

I'd like to exctract only one record from duplicates records (for example in a field "test") using "exctract by expression" in qgis. Some records could be not duplicates, and ...
user avatar
  • 661
1 vote
0 answers
30 views

FilterExpression only work in form

I make a QGIS plugin for 3.10. and use Relational value but my key is 2 thing. a string a int So I use the key colonne as my int and add a filter expression to add key "TYPE_MAT" = ...
user avatar
  • 131
6 votes
1 answer
109 views

QGIS label: expression to show the maximum value to label in the map irrespective of the scale

I have the following attribute. I would like QGIS to prioritise only the maximum value from field1 while labelling. In other words, on the figure 2 (zoomed out version of figure 1), I would like to ...
user avatar
  • 467
0 votes
0 answers
39 views

Specific ID attribution pattern past 100 entities

I have an ID attribute which looks like this on the attribute table of a given layer: A00 A00 A00 A01 A02 A03 ... A98 A99 A00 is specifically given based on a certain attribute manually given (for ...
user avatar
0 votes
0 answers
32 views

Calculating polygon areas using Field Calculator in PyQGIS [duplicate]

I am trying to calculate areas for polygons in QGIS 3.16.10 using PyQGIS 3 as you would with the Field Calculator. I am trying to use QgsExpression to create the necessary expression. However, the API ...
user avatar
6 votes
3 answers
246 views

Calculating cumulative SUM in QGIS Attribute table

I'm trying to get the cumulative sum of the column "uren_duur" in a new column "uren_tot" based on the recorded water height "NUMERIEKEWAARDE". The water height ranges ...
user avatar
  • 61
7 votes
2 answers
263 views

Creating field with 1/0 values depending if point sits inside polygon in QGIS

I have a layer with a single polygon and a layer with multiple points. Some of the points are inside the polygon. How can I create/update a field with a value of 1 (true) or 0 (false) depending if a ...
user avatar
7 votes
4 answers
262 views

Labelling with first letter taken from each word in string using QGIS

I have a field called "Species" which is composed by two words (e.g. 'Robinia pseudoacacia') and I would like to extract the first letter of both the words in order to get two letters (e.g. '...
user avatar
5 votes
2 answers
257 views

Selecting only one minimum value by expression in QGIS

If there are two values that are equal and minimum, the minimum function in "Select by expression" returns both of them. Is there any way to select by expression only one of them? If not, ...
user avatar
3 votes
3 answers
235 views

Removing the time zone from datetime field in QGIS

How can I get rid of the time zone in the date/time field? So I have a GeoPackage with the following data: and want to get just 2021-06-07 16:25:40
user avatar
1 vote
1 answer
166 views

How to use a QGIS expression using a Python function with custom named argument(s)

I have a Python function that I simply use as a label expression in a print layout. Its objective is to render elements from a json object stored as a field in a vector layer. This vector layer is ...
user avatar
  • 6,748
3 votes
1 answer
132 views

Getting fieldnames with QGIS expressions in same order as in attribute table (not alphabetical order)

Context I want to get a list of field names of a layer using QGIS expressions. The function attributes() returns a key:value map of the attribute names and values. By default, the result is sorted ...
user avatar
  • 41k
5 votes
2 answers
109 views

Expression to fetch polygon value intersecting end of line

I have a line layer and a polygon layer. I'm trying to create an expression to fetch a polygon attribute and add it to the line, based on in which polygon the line ends. array_last(overlay_intersects('...
user avatar
  • 52.2k
3 votes
2 answers
243 views

Query for rendering all possible combinations of array of values in QGIS

How can I query the symbology of a layer so that I have as many symbols as all possible combinations of "chrono1", "chrono2", "chrono3"? I'm looking for an automatic way ...
user avatar
  • 578
3 votes
1 answer
82 views

Select an attribute value with the Expression String Builder in QGIS

I'm working with QGIS 3.16 Hannover and this should be very straightforward but I'm unable to solve it. I'm producing different maps, filtering the features of a layer. In the composer manager, I'm ...
user avatar
  • 2,283
3 votes
1 answer
161 views

"No feature was found..." when making custom grid coordinate format

I'm in QGIS layouts trying to make a custom grid coordinate format but get the error: No feature was found on this layer to evaluate the expression. This error does not appear if I have a single ...
user avatar
  • 283
4 votes
1 answer
62 views

Is it possible to filter the attribute table in several years at the same time?

I have a very extensive attribute table (see screenshot) and would now like to filter the objects according to certain years (1997, 2002, 2009, 2014 and 2018) and, after that, biotope types. I think ...
user avatar
2 votes
1 answer
178 views

Getting the mean value of each row for the final column in QGIS

I am trying to calculate the mean/average of all the values in a row to obtain the final value i.e., "IRAT". How can I calculate it automatically using a field calculator in QGIS? for e.g., ...
user avatar
1 vote
0 answers
77 views

Reading @map_id expression variable using PyQGIS

When I try to read the expression variable @map_id using a Python expression function (see code below) inside a label text, it always returns "canvas" as result. When I use @map_id directly, ...
user avatar
  • 3,653
1 vote
1 answer
137 views

In QGIS Atlas how to get the index and the number of features grouped/filtered by an Attribute with expression?

Using a QGIS Expression in the Layout Editor, how can one return the count of features matching a particular attribute value for an atlas feature, for example, "AREAS_Area". In this ...
user avatar
  • 2,609
10 votes
1 answer
156 views

Selecting NULL or date values by Expression in QGIS

How can I select by expression from a date field in a shapefile, dates that are NULL or >= 2020-01-01? This doesn't work, it only selects those with dates >= 2020-01-01, not the NULLs "...
user avatar
  • 52.2k
5 votes
2 answers
601 views

QGIS expression on layer that refers to intersects on same layer

Let's say I have the scenario where: Polygons A and B intersect polygon C There are also polygons X,Y and Z which do not intersect C. Polygon C has an attribute value 'Priority' which I need the ...
user avatar
  • 2,744
2 votes
1 answer
45 views

Print out centroid coordinates of a polygon in layout text box

I wanted to put the coordinates of the centre of a polygon in a text box in the print composer. When I run the expression in the labelling panel on the canvas it works, like below However, when I run ...
user avatar
1 vote
1 answer
125 views

Buffer by field value in the processing modeler in QGIS

I am using the processing modeler in QGIS 3.10. I want to buffer polygons by individual field attributes. This is not a problem when I am not using the processing modeller since one can simply choose ...
user avatar
3 votes
0 answers
69 views

Populating row numbers with Field calculator using PyQGIS

I have the following code, which is creating a new column called "group" without issue, but not populating it with a row number 1-n, as I'm intending it to. pv = layer.dataProvider() pv....
user avatar
  • 575
2 votes
1 answer
139 views

Filtering features outside features of another layer using QGIS geometry generator

I am trying to filter features in one layer outside features in another layer using geometry generator. I have a buildings layer and an area layer and now I want to only show the buildings outside the ...
user avatar
  • 389
0 votes
0 answers
62 views

How to handle NULL values in QgsExpression()?

When I try to add multiple conditions in QgsExpression() eg: QgsExpression(f"input='{abc}' OR value='{def}'") here abc = 1 and def = NULL. Even though abc is having value I am getting NULL ...
user avatar
0 votes
1 answer
37 views

QGIS Fieldcalculator

I have a QGIS layer with points and the column 'name'. This column contains names like "AS 10450 to 1045" or "BAS 1045B100 to AS 1457745". Now I want to create another column with ...
user avatar
5 votes
3 answers
449 views

Creating line from points and counting the number of points on that line

I have a shapefile that contains a number of points, each point represents a tree. I would like to calculate how many trees there are per row. Hence my question (I think this is the best method), how ...
user avatar
  • 59
2 votes
1 answer
297 views

Format multiple values in a label with different colors in QGIS

I need to create complex labels for sites that contain multiple values in each. These values are colored depending on their value (ex. in range = green, out of range = red). I need to do this from an ...
user avatar
2 votes
1 answer
578 views

Expression to Transform XY coordinates to LatLong in QGIS

I have a Point Layer referenced in a projected CRS (UTM) with X, Y and Elev fields that represent coordinates of some points I have surveyed. I would like to have in the same layer Lat and Long fields ...
user avatar
1 vote
0 answers
58 views

DB Manager returns NULL for GeoPackage layers

When I try to do some spatial query in the DB Manager (as Virtual Layer Provider) or in the Virtual Layer Window (Layer > Add new Layer > Create Virtual Layer...) it returns a NULL array, as it ...
user avatar
2 votes
1 answer
24 views

Map not changing after filter

I use qgis 3.4.4 and I make a filter on vector layer. Here is my code: layers = QgsProject.instance().mapLayers() for layer_id, layer in layers.items(): if (layer.name() == "csv_points_acc&...
user avatar
  • 245
0 votes
0 answers
205 views

Apply a date filter to the vector layer

I am new to developement in QGIS. I use a the 3.4.4 version of QGIS. My vector layer is like this: So I want to know how to filter this data by date and apply the changes in the GUI. Here is what I ...
user avatar
  • 245
1 vote
0 answers
113 views

How can I made requests (QgsFeatureRequest) or selections (selectByExpression) from a list of QgsFeature?

I've got a processing algorithm that does a request to select some features that correspond to the incorrect filling of the attributes. It reads a JSON file containing a description of expression (...
user avatar
3 votes
1 answer
139 views

Calculating distance betweeen classified points in QGIS

I got two sets of points. The first set has a unique "ID" The second set references to this "ID" (one-to-many). So I merged the two sets. Now every point in the joined table has ...
user avatar
4 votes
1 answer
105 views

Filling field with automatic numbering specific by unique value of another field using QGIS expression

I have a table with two fields: "NUMBER" (integer) and "TOWN" (text). I would like to find an expression that fills the "NUMBER" field with an automatic number specific ...
user avatar
  • 389