Questions tagged [qgsexpression]

class for parsing and evaluation of expressions in QGIS API

Filter by
Sorted by
Tagged with
1
vote
1answer
46 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 ...
3
votes
1answer
72 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 ...
5
votes
2answers
86 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('...
3
votes
2answers
187 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 ...
3
votes
1answer
46 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 ...
3
votes
1answer
87 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 ...
4
votes
1answer
55 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 ...
2
votes
1answer
76 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., ...
1
vote
0answers
44 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, ...
1
vote
1answer
104 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 ...
10
votes
1answer
140 views

Select By Expression, NULL or date

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 "...
5
votes
2answers
281 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 ...
2
votes
1answer
39 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 ...
1
vote
1answer
73 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 ...
3
votes
0answers
51 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....
2
votes
1answer
60 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 ...
0
votes
0answers
20 views

Extract specific geometry type from a QuickOSM query in QGIS graphic modeller

I am trying automate the extraction of various features from OSM using QuickOSM in GQIS graphic modeller. I have the query etc running fine but I want to end up with just the lines and export to a ...
0
votes
0answers
31 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 ...
0
votes
1answer
32 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 ...
5
votes
3answers
311 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 ...
1
vote
1answer
102 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 ...
2
votes
1answer
281 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 ...
1
vote
0answers
43 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 ...
2
votes
1answer
22 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&...
0
votes
0answers
139 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 ...
1
vote
0answers
81 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 (...