The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [expression]

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

Filter by
Sorted by
Tagged with
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.
15
votes
2answers
16k views

How to select features containing specific text string using an expression in QGIS

I need to style a survey parcel polygon shapefile, based on whether the polygon is a mineral claim or not. Unfortunately, the only information on whether a polygon is a mineral claim or not is ...
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% ...
11
votes
1answer
887 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 ...
9
votes
1answer
242 views

Using some 'temporary variables' in QGIS Geometry generator symbol layer type expression?

Making use of the Geometry generator symbol layer type, I draw rectangles of dimensions @nv_bg_w (width) and @nv_bg_h (height) (project variables) to line features, either at coordinates text_x, ...
8
votes
1answer
212 views

Accessing QGIS map canvas as a variable for expressions

Is it possible to access the QGIS Map Canvas as a variable or expression value to be used in the field calculator or labelling engine? (i.e. so that you can create an expression that selects/...
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
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 ...
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'"...
7
votes
1answer
289 views

Expression in field calculator to pick out multiples of x

I have an attribute table of contours at intervals of 10m but I wish to label the layer at intervals of 50m. My method was to create a new field with an expression which would copy the entries in the ...
7
votes
2answers
789 views

QGIS using project variables in filter queries

In QGIS 2.14.11 LTR I have to apply the same (or similiar) filter query to various layers. I have the road name to filter for in a project variable and try to apply the following query: "road_name" = ...
6
votes
3answers
1k views

How to select specific rows of polygons from a grid in QGIS?

I have a polygon layer. I would like to select every second row of the polygons but not manually. Is there an expression to select every second row as seen on the picture with Select by expression in ...
6
votes
1answer
154 views

Expression to change an attribute each X number of rows

I'm using QGIS and I need an expression to change an attribute each X number of rows. For instance I have the next attribute data: I want to create an attribute (C) that assigns an ordered value each ...
6
votes
2answers
121 views

QGIS 3.4 calculate date, add month

I want to add a number of months to a date to get a new date. I have a date-field "date", an integer-field "months" and a date-field "new_date". I want to calculate the "new_date" by adding the "...
6
votes
1answer
1k views

Aggregating with attribute($currentfeature) filter in QGIS

Why doesn't the filter work (4th variable passed into the aggregate function) when I try to use in the field calculator an expression of this type: aggregate( 'Layer', 'sum', "Field1" , "Field2" = ...
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 ...
5
votes
3answers
575 views

How to escape percent in a LIKE expression in qgis?

How can we escape a percent character in a LIKE expression in QGIS? For example, if I have the following column: 123% , 15% , albert, greg, 15% How do I select all the values with % in it without ...
5
votes
2answers
937 views

QGIS atlas, add picture with path from attribute

I love working with the atlas generator and I came up with a new case to use it for. I want to add a picture to my map from URL. I am allowed to add a picture if I type in the full url path. eg. http:/...
5
votes
1answer
159 views

Test for (curly) brackets in expressions in QGIS 2.14.14 with strpos() weird results

When trying to find a strpos() of a substring containing curly brackets (or brackets anyway as far as I can see) I get 0 as a result. Test for substring without {} works fine: Test for substring ...
5
votes
2answers
167 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/...
5
votes
1answer
175 views

Using a loop in a python expression to stack labels while avoiding zero value attributes

I have a number of point features in a map in ArcMap 10.6 that I would need to label based on information form three fields (Test1, Test2 and Test3) with numeric values. The labels from these 3 fields ...
5
votes
1answer
961 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 ...
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 ...
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
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
2answers
279 views

Correct SQL expression when looping different fields

I'm having trouble with the follow lines of code. Practically what I am doing is a 10 shapefile loop in which field represents the name of the field that I want to be calculated( the name differs by ...
4
votes
2answers
158 views

Dropping & inserting specific characters within a field being used for labeling

I would like to find out how to properly format a conditional expression in labeling, so as to only get specific characters back out of a field that has 9 characters in it, but don't wish to label ...
4
votes
2answers
69 views

Adjusting condition in field calculator in QGIS [duplicate]

I need to calculate a score based on an area field using these ranges: if >= 30000 (square meters) then 4 (score) if < 30000 AND >= 10000 then 3 if < 10000 AND >= 5000 then 1 if &...
4
votes
2answers
116 views

Exempting “of” and other similar strings in title('string') in QGIS expression based labelling?

I have a field name where all the values are capitalized so I used title('string') to get my desired results: 'OLONGAPO CITY' will result to 'Olongapo City'. However, there are strings such as: ...
4
votes
2answers
198 views

QGIS - How to differently colorize labels from two separate fields using color expression script?

I have 2 fields, I concatenate them [concat(to_string(field1), ' ', to_string(field2))] to show their labels side-by-side. Is it possible to colorize from "text color expression" (using some scripts) ...
4
votes
1answer
297 views

QGIS Expression Builder: returning pair of values (e.g.: coord)

Seems like this should be simple, meaning I'm probably "trying to do the wrong thing," but: I have a field (specifically, Label Placement's "Offset X,Y") that expects an input of type double coord. I ...
4
votes
2answers
287 views

Attribute table : How to select more then one feature?

I have a vector layer: ROADS that is composed of different types of roads: primary, secondary, tertiary, trunk, etc. When I right click on the layer ROADS and I go to Attribute table -> Select by ...
4
votes
2answers
577 views

ERROR 000539: Error running expression

I am trying to calculate my End_Streets field within two joined tables. I want to remove the redundant SECONDARYN value from the STREETS field. " & ".join(!IntersectAndEnds2.Streets!.split(" &...
4
votes
2answers
383 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
1answer
508 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 ...
4
votes
1answer
394 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
40 views

Checking if value from one column is in multiple other columns

How do you write an expression for a style rule that will check if the value from column A exists in columns B, C, D & E? I have a polygon layer that I would like to flag with a style depending ...
4
votes
1answer
191 views

How to return array from label offset expression? [duplicate]

I am trying to set the x,y offset of layer labels based on a data defined override. What I'm trying is the following: CASE WHEN name is 'Brooklyn Bridge' [3.5, 0] ELSE [-3.5, 0] END However this ...
4
votes
2answers
220 views

Missing 'values' picklist in QGIS expression builder

Recently converted to QGIS 2.18.2 from Mapinfo under Windows10. The Expression Builder in all the menus I've tried fails to display a popup window of values under the 'fields and values' selection ...
4
votes
1answer
628 views

How to write EXPRESSION for main contours in Mapfile?

I'm working with mapfile. I defined new layer "contours" and I want to render with maxscale = 100000 and minscale = 50000 contours with value distance of 50. That means that I want in that scale ...
4
votes
1answer
3k views

How to create an Arcade Expression that excludes empty field values

In ArcGIS Online, I have a point layer with attributes Provider1, Provider2, Provider3.....Provider13. The values are text consisting of people's names. I would like to configure the popup to ...
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 ...
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 ...
4
votes
1answer
112 views

QGIS: Select point(s) in other layer with similar datetime value from selection

For the interpretation of bird observations, I need to identify the position on a GPS-track (gpx-files), from which the position of a bird observation (other gpx-waypoint layer) was recorded. The ...
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
147 views

How do I convert a string into a column number in QGIS Expression Builder?

I want to highlight parts of a map based on the page number in an atlas. Ideally I'd use the expression builder in the layer style menu to set the Column to equal the atlas page number. My expression ...
4
votes
0answers
38 views

Displaying images as part of multiattribute labels using QGIS

I would like to display images referenced in an attribute column as part of a multiattribute label, so that I can eventually print them with the map. I do not want to display geotagged images, since ...
4
votes
0answers
80 views

Set background or text color depending on expression in an attribute table in QGIS composer

I am using QGIS 3.0.2. I am working on a print composer including an attribute table. I would like to set different colors to each rows, depending on an expression, refering to an attribute. I didn't ...
4
votes
0answers
208 views

Using transform function in QGIS layer geometry generator?

I'm trying to use the following expression in the geometry generator in a QGIS layer to show a 1-mi boundary around points: buffer(transform($geometry, 'EPSG:4326', 'EPSG:2877'), 5280) However, the ...
4
votes
0answers
200 views

QGIS Color text labels the same color as the feature [duplicate]

Using QGIS 2.12.1 on Ubuntu 14.04 Desktop. What I have is a layer where each feature is a different color. I also want to label each feature but I want the label colors to match the feature colors. I ...