Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [expression]

Expressions are SQL-like statements that are used to evaluate dynamic properties.

Filter by
Sorted by
Tagged with
6
votes
3answers
1k views

Achieving Super or Subscript graticule labels in QGIS Composer windows?

It is quite common for paper topographic maps to label the map graticule with ordinate values in a mixture of superscript and standard digits, eg. ⁴123⁰⁰⁰ to emphasise the significant digits. The ...
7
votes
1answer
1k views

How to build a query/expression to select specific points within a buffer? (in QGIS)

I have a point layer in QGIS. Each point represents a tree and each tree has information about its height as an attribute. I would like to build a query/expression to select all those trees that have ...
11
votes
1answer
888 views

QGIS query syntax differs between attribute table and feature filter

Using QGIS 2.16.2, I can successfully select records from a shapefile attribute table using the following expression: left("start_time", 10) = '2015-08-01' Please note that start_time is a string ...
4
votes
2answers
1k views

Getting currentfeature's color in Expression Builder of QGIS?

In QGIS Expression builder. I want to obtain the color code of the current feature. I mean: My layer contains lines, each one is painted with a different color. Now I want to assign that color to ...
20
votes
3answers
19k views

Learning to use expressions in QGIS?

Is there any resource recommendations in general for getting past the basics of QGIS and going into the deep dark secrets? Specifically in relation to expression coding for labeling, queries, etc.
5
votes
1answer
963 views

referencing to features geometry in an expression

I have a layerA with roads and a layerB with one shortest path. If I put an aggregate function into a virtual field in layerB to calculate the sum of fieldAA where the shortest path contains features ...
3
votes
2answers
10k views

QGIS Multiple CASE WHEN/THEN Statements for Expression Based Labels

I am trying to label a single point with multiple labels, based on the attributes for that point. For example, if one of the attributes is equal to 1, I want to label it with a specific text string; ...
3
votes
2answers
13k views

Using QGIS to Select by Expression?

A basic QGIS 2.2.0-Valmiera, Select By Expression - Field Calculator question. Introduction I am a geologist searching through a geological database (see attached figure). I have a shapefile and ...
1
vote
1answer
1k views

Creating multiple lines label in QGIS?

I try to create a multiple lines label for this this polygon: I red How to create multiline labels in QGIS? QGIS, Multiple lines and wrap on character? and tried to use the "wordwrap" function ...
1
vote
1answer
84 views

MultiValue-String to SQL Expressions

I am aware that problems like mine exist (example) but I think, this is slightly different. I want to use MultiValue to let the user choose various inputs at the same time. The problem is, that it's ...
4
votes
1answer
398 views

Summing up the area on a polygon by a certain attribute result

I wish to know if there's a tool on QGIS equivalent to the Excel's "SUMIF". I have a shapefile of a land use and cover that's classified by the attribute with the name of the classes, for example: "...
4
votes
1answer
513 views

Using round function in QGIS expression?

I created a grid of rectangular polygons with the Create Grid function, from the Vector Creation group of the Processing Toolbox in QGIS 3.4.2. The rectangles measure half a degree of longitude by ...
2
votes
2answers
975 views

Limiting available values in dropdown field of QGIS form according to value selected in previous field?

I'm building a rather complex entry form for a layer stored in a PostGIS database. I am following this usage scenario: On several occasions I have dropdown fields which lets the user select a type of ...
2
votes
2answers
3k views

How to convert decimal point to comma in QGIS?

I am working with data in Colombia where decimal points are written as commas. I would love to create a new column in QGIS that would convert all decimal points (periods) to commas for the purpose of ...
7
votes
3answers
1k views

Difference between quotation marks ('single' vs “double”) in QGIS

I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double"). I know something about the quotation marks and the way they are applied in Python ...
7
votes
2answers
2k views

How to build QgsExpressions in python?

How can I build a feature request expression using variable inside expression? For example values = [1, 2, 3] for j in range( y ): it = vl.getFeatures( QgsFeatureRequest().setFilterExpression ( u'"...
4
votes
2answers
384 views

Copy/convert selection into filter/query builder of QGIS?

Can anyone tell me if it is possible (and how) to convert or copy a selection on a layer (that has not been created through "select by expression", but instead by irregular selections from a canvas, ...
4
votes
3answers
183 views

Automating citation of data source in QGIS print composer?

I have 20 thematic maps with different sources like CITY PLANNING OFFICE, ENVIRONMENT OFFICE, AGRICULTURE OFFICE etc. Since I have many maps, I want to automate the data source citation of my ...
4
votes
3answers
817 views

Quickly make server side spatial filters for WFS layers based on other layer's selected geometries in QGIS

In QGIS 2.12.1, I have a WFS layer which is huge so I don't want my users to load it entirely but only parts of it based on intersections with geometries. Today, I'm using the query builder and ...
3
votes
2answers
233 views

Summarizing Fields based on content in QGIS?

already read many answers for similar questions, but i didnt find a solution for my problem. Dont know how to start. Problem: shp with about 50 fields. Each field contain NULL, 1 or 2. Now i need ...
3
votes
1answer
210 views

Building Expressions for QGIS Markers

I have a tab delimited text file with a column "Status". It can have values OFF-AIR or ON-AIR. How do I control the marker properties like colour or out-line using the expression building. I am not ...
2
votes
1answer
2k views

If-then expression in Mapinfo label expressions

Firstly this is similar to If-Then Label Expression BUT I need this for Mapinfo. So I want to do the following in Mapinfo in the label expression box in ver 12. if RuralAdd='R': address=St_No + " ; ...
13
votes
3answers
3k views

How to set transparency per polygon in a shapefile in QGIS?

How to set transparency per polygon in a shapefile in QGIS? For example: a polygon with field "value" = 1 should be fully transparent whereas field with field "value" = 0.4 should have a 40% ...
5
votes
2answers
169 views

Is it possible to distribute custom python expressions along with .qgs file?

I have a QGIS project I'm working on with a few other users. The print composer and map tips use custom python expressions in the expression builder. I know the expressions are store in .qgis2/python/...
4
votes
1answer
189 views

Geometry by expression in QGIS Modeller

I want to use 'Geometry by expression' in a model I'm working on but I couldn't figure out how to pass the layer name parameter. Basically I have two polygon layers (A and B) and I want to do a ...
4
votes
2answers
2k views

How to extract a part of string from fields in QGIS field calculator?

I want to create a new field in my attribute table. My goal: returning all digits between the / and _ characters of the field named "location" by applying the next expression: regexp_substr( "Text", ...
4
votes
3answers
11k views

If-Then Label Expression

I'm trying to create a VB label expression on streets such that streets with an alternate name (ACS_ALIAS) will be labeled with the LABEL name and the alternate name in parentheses; streets with no ...
3
votes
1answer
196 views

How to apply a default datum transformation in an expression in QGIS

I'm using the expression: x(transform($geometry, 'EPSG:32632', 'EPSG:3003')) to add coordinates fields according to different CRS in a point layer. To obtain better accuracy i need to apply a Datum ...
3
votes
2answers
419 views

Label expression in ArcGIS gives TypeError coercing to Unicode need string or buffer NoneType found?

I try to build stacked label expression in ArcGis 10.3.1 with this expression: [name3] + '\n'+ [results] name3 and results are two columns in the attribute table. But I get this error: ...
3
votes
2answers
1k views

Filtering a layer with attribute value from another layer in Qgis 2.18

I am pretty new to Qgis and a real beginner when it comes to working with expressions in Qgis. Maybe someone can help me with following problem: I have several Layers (like Building + House) and ...
3
votes
1answer
1k views

Selecting features in attribute table using maximum aggregate function

I have a table containing distances from one ID (an address) to another ID (bus stops). There table contains distances from all addresses to all different bus stops. Now I want to select the feature ...
3
votes
1answer
66 views

Calculating the number of days between two dates as number

For some expression in QGIS I need to get the number of days between two dates as numeric value. If I substract two dates I get an interval back: to_date('2019-12-31') - to_date('2019-01-01') gives ...
3
votes
2answers
1k views

How to optimize QgsFeatureRequest with filter expression

I have a point PostGIS layer (my_layer) which has more than 66000 features. I am getting the features I want but it takes too long. My code is: resultList = [] req = QgsFeatureRequest()....
3
votes
2answers
2k views

Handling NULL values in labeling? [duplicate]

In QGIS (2.10.1 on a Mac), I am trying to make some multiline labels on a map I have with a bunch of trees in them. In the attribute table I have columns with the Latin scientific name, the English ...
3
votes
3answers
3k views

Using 'max()' in expression with QGIS?

I want to make a rule-based style on the maximum value from a field. I set my expression like: max("fieldname") It returns every value instead of only the maximum one. Can anyone tell me the right ...
2
votes
3answers
130 views

QGIS Select by expression - buffer selection

I want to select points 2 and 3 with a 'selection with expression' in QGIS 3.4. I want to do this by using the buffer function in the expression builder. I already managed to create a separate ...
2
votes
1answer
736 views

Get value of Variable in custom python expression function

I am writing a custom python expression function to return the value of a variable. By variable, I mean the layer, project, or global variables. I looked at this answer https://gis.stackexchange.com/a/...
2
votes
1answer
181 views

How to create a 'dummy' DATETIME field for QGIS timemanager?

We have several 'time-aware' datasets, but the dates are stored as YEAR (2017), SCHOOLYEAR (20172018), etc. rather than a true DATETIME value. In order to animate these datasets, is it possible to ...
2
votes
0answers
281 views

Label only one polygon in canvas/map view per category/value in attribute table

Question: In QGIS (2.18), how do you show only one label per field of view in the map canvas for each visible category (that is displayed in the map view/canvas at any given scale/focus) of a multi-...
2
votes
2answers
1k views

Search for string and only display characters before it in Mapinfo label expressions

So I have a property table that has addresses like below. 12 Andrews CL, Pxxx 1/12 Andrews CL, Pxxx 2/31 Macrossan ST, Pxxx 2/7-11 Barrier ST, Pxxx I need to only show 12 1/12 2/31 2/7-11 Can ...
2
votes
0answers
95 views

Calculate length of selected features in PyQGIS

I create a selection with getFeatures(QgsFeatureRequest()) and I want to calculate the length of the result which is a QgsFeatureIterator : select = QgsExpression(" myexpression ") selectedfeats = ...
1
vote
0answers
120 views

QGIS Expression Calculator Field Shows Null

When I go into the expression builder under the "Field and Values" drop down on the left side, instead of a list of field for the layer all it says is NULL. Is there something that would cause this ...
1
vote
0answers
40 views

Define color for label-buffer with data-defined override/expression

In QGIS 3.8 (Win 10) I have a Point-Layer with labels in a certain distance and leader lines, created with geometry-generator. The leader lines in some cases cross below the label and are masked by a ...
1
vote
1answer
103 views

How to query 1 feature of each category using QGIS (SQL like) expression language?

I use QGIS 3.2 to select features in a shapefile. Lets say I have shapefile which contain 100 features and have such fields: Class with possible values A,B,C. ID with possible integer values 0, 1, 2, ...
1
vote
0answers
46 views

How would I build the syntax inside a request in the case I wanted to multiply 2 variables?

I would like add something to my previous question (here: How to build QgsExpressions in python?) How would I build the syntax inside this request in the case I wanted field_name to be also a ...
1
vote
1answer
368 views

Label only selected features with PAL PyQgis using an expression

I'm trying to label only selected features with an expression using PyQgis and the PAL functions, but I don't find any example and the API don't help me a lot (or I don't found it). My Qgis version is ...
1
vote
1answer
292 views

QgsExpression to apply on feature

I am using QGIS 2.8. For the documentation of QgsExpression I see the evaluate method on feature as deprecated. What am i supposed to use instead of this methods ? I have some expression and need to ...