We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [expression]

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

Filter by
Sorted by
Tagged with
4
votes
0answers
84 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
213 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
209 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 ...
3
votes
2answers
427 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
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 ...
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
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
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 ...
3
votes
3answers
714 views

Creating QGIS text label in composer calculating values from attribute table?

I am working with QGIS 2:14, for now, I have a qgs project with a lot of layers and I want to create a label in the print-composer with the result of a calculated expression from one of this layers. ...
3
votes
1answer
224 views

Deleting a common word in attribute table

I have a dense attribute table of all the districts in the UK. I want to label the districts but each row in my 'NAME' field has 'District' after it. I wish to take this off, only leaving the name of ...
3
votes
2answers
370 views

QGIS expressions on potential columns

I have al lot of shapefiles who share zero, one, some or all fields. I want to write an expression that can be used on all of the shapefiles. I was wondering if there is something like if "field1" ...
3
votes
1answer
57 views

Auto populate qgis file name with no file extension?

I'm looking to be able to auto populate an attribute field with the project file name either by a virtual field or default option in the properties. The "@project_filename" expression always produces ...
3
votes
1answer
276 views

Complicated expression for Calculate Field for arcpy

I have a working formula that I can put in the Field Calculator which I'd like to use in my python code: .3-.001*Log ( [Field1]+1 )-.02*Log ( [Field2]+1 )-.04*Log ( [Field3]+1 ) My code: ...
3
votes
1answer
673 views

Displacing colliding point symbols in QGIS

I have a layer that includes points for electric poles (Circles) and transformers (triangles). Transformers can be on poles or on their own. I would like to displace the transformers only if they are ...
3
votes
2answers
377 views

Using Map Tips and Ruled Expression in QGIS?

QGIS 2.18.5 I'm trying to add a condition to my expression in my html/css map tips where if a value is 'null', the result will show 'no data available'. I've got a screenshot of my map tip so far ...
3
votes
1answer
402 views

Custom labeling expression in QGIS?

I'm trying to use an expression to label a layer by using the "name" field but only if it has certain entries from the "type" field. The expression I've tried is: NAME IF "TYPE" IN ('RIV-MAJ', '...
3
votes
1answer
157 views

QGIS Expression builder cannot filter

"name" like 'column%' Output preview: 0 or "name" = 'column_title' Output preview: 0 No filtering results in expression. Tried Qgis 2.12 and 2.18 both on OS X. Data is from Open Street Map - ...
3
votes
2answers
949 views

Filter expressions on attribute table

I'm new on QGIS, I have shapefile for the whole country and also have for Province down to City/Municipalities, is there any way on attribute table where I can filter using an expression for example: ...
3
votes
1answer
771 views

How do you label only the odd or even integers of a field using python in the label expression in arcmap?

I'm new to python and would like to use the label expression box with python to display only the odd or even integers from the field, [Frame_Number]. I was thinking something like def FindLabel ( [...
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
1answer
50 views

Overlining text label in ArcGIS Desktop

I would like to know is there anyway to overline a text label like this in ArcGIS10.3.
3
votes
1answer
71 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
1answer
324 views

Using expression to number unique string values consecutively in QGIS?

I have a set of string values in a shapefile's attribute column and want to assign a number to them in a way that each unique string gets an integer number, like this: strings numbers ------- ...
3
votes
3answers
828 views

QGIS Query Editor define variable

I am relatively new to QGIS. I use conditional formatting for various problems. In the qgis query editor, I would like to define a string variable for further usage, so I wouldn't have to retype the ...
3
votes
3answers
331 views

Show all points (airports) in featured country only

I need to generate maps showing all airports located in a featured country. My airport shapefile has over 8000 points, so I need to remove those that are irrelevant. Example: When Sweden is featured, ...
3
votes
1answer
511 views

Set expression in QGIS edit widget relation reference with PyQGIS

I've setup an edit widget for a field as a relation reference like shown below and save the configuration as a QGIS layer style file (*.qml): With PyQGIS I do the following steps load the vector ...
3
votes
1answer
43 views

Coalesce field “X” if field “Y” is a duplicate

(QGIS 3.4) The image below will help explain my goal: I'm working out how to coalesce the attributes of the field "ID" if the field "X, Y" is a duplicate. I have highlighted some duplicate ...
3
votes
1answer
103 views

QGIS 2.18 label by expression concatenate field strings

For a building layer I have an attribute table with several fields for the building type where data was entered with a manually created form using checkboxes. Example: Production: 1 = (yes), 0 = (no) ...
3
votes
1answer
99 views

Styles with parameters

I'm using QGIS 3.4 , and without going into python scripting, is there a way I can create some kind of rule based styles where I can add a parameter? I have a number of layers, each with between 1 ...
3
votes
1answer
179 views

QGIS Densify Geometries based on expression

I tried using the Expression Based Input in the Densify Geometries tool with the following expression: attribute( $currentfeature ,'VertNum') where VertNum is a field in the attribute table that ...
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
2answers
195 views

Calculating a percent from attributes in label expression

I am trying to edit my existing python code in the label expression in order to add one more bit of information to the map. The purpose is to automate fire maps creation through data driven pages for ...
3
votes
1answer
69 views

Using expressions to relate column to layer style in QGIS?

I have a QGIS project with N layers, each pointing to the same CSV file with columns "1_1, 2_1, ..., N_1". I would like each layer to refer to its respective column (Layer 1 -> column 1_1, and so on) ...
3
votes
1answer
84 views

Buffer with unknown distance by adding numerical values of a column until a maximum

In my QGIS project, I have a vector of polygons representing slope zones around an archaeological site and I want to calculate the area which is necessary to supply the ancient population with a ...
3
votes
1answer
114 views

QGIS 2.18: Speed up QgsFeatureRequest in Python Script

I have two input layers. The first one is a line-layer named "graph" and the second one is a point-layer named "nodes". The "graph"-layer: The graph layer holds 177350 line features which are ...
3
votes
1answer
215 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
1answer
285 views

arcpy CalculateFieldManagement - single quotes in expression

I'm using the following to write a value to a field. arcpy.CalculateField_management (newPha, "PHACODE", """'{}'""".format(name), "PYTHON_9.3") The only problem is that the string I'm attempting to ...
3
votes
1answer
211 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 ...
3
votes
2answers
304 views

Select by expression functions in QGIS 2.8.2 (Windows)?

Please forgive me if this is obvious, but having opened a newly installed version of QGIS on Windows, I can't seem to see the list of functions normally present (as shown in the Mac image) in the '...
3
votes
1answer
38 views

Get Attributes from 1:n relation in QGIS as Expression to use in Atlas

I need to set up way signs for something like a "hiking-GIS". In the first step I made a network analysis (using QNEAT3) to find the distance from the signs ("Way Signs") to the available destinations ...
3
votes
1answer
43 views

Getting value set in binding input widget in QGIS expression?

I would like to set dynamic line width and it should be scaled by the value "Stroke width". When I set the value to 0.15, it will be less than 0.15 if $length is too small. I need a function to get ...
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
272 views

QGIS 2.18.4 show '0' value disappear with labels with rules [closed]

I need help to show '0' value with expression. When I show only label from a row, '0' appear, but I want to add the expression in the color : CASE WHEN "max_44_mol_pharma" < 100 THEN ...
3
votes
1answer
528 views

Adding lines connecting labels to points in QGIS?

I'm working on a map that has a lot of points in a small area, so I'm adding lines from my labels to their points using a Geometry generator in the symbol designer. The problem I'm having is that the ...
3
votes
2answers
234 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
0answers
25 views

Label only the maximum value when I zoomed out or print in smaller scale using QGIS

I would like to prioritise the maximum values to be shown on the map. In other words, when the label collides it should drop out the minimum values. In the shown examples, I would like to have ...
3
votes
0answers
89 views

Updating shared custom functions / expression code in QGIS

All the QGIS documentation I've seen on custom functions (used in expressions) says that the code is saved in the user's local expressions directory, e.g. ~/.local/share/QGIS/QGIS3/profiles/default/...
3
votes
0answers
111 views

Create multipoint layer from array by expression

I have two layers. One shapefile point layer, called "point1" and one csv no geometry layer, called "Meta". "point1" looks like: id bd 1 a 2 b 3 c 4 d 5 e 6 f and so on... "...
3
votes
2answers
226 views

Rotating features generated by the geometry builder

In QGIS I have a point feature with "Rotation" field. Using the geometry builder I am trying to build square geometries based on the XY as centre and rotated based on the "Rotation" field using the ...
3
votes
0answers
143 views

Custom QGIS expression to filter atlas pages

I want to filter my atlas pages based on a list returned by a custom function but it won't work. This is my function: from qgis.core import * from qgis.gui import * from qgis.utils import * @...