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
2
votes
2answers
848 views

How to concatenate strings separated by dot in PyQGIS?

I would like to concatenate the string of field1 with field2 separated by dot and so on. However, when I put the "." the attribute values remain null. How to separate string by dot? e = QgsExpression(...
3
votes
1answer
280 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 ...
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 ...
3
votes
1answer
493 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
2answers
373 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 ...
2
votes
2answers
689 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. ...
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: "...
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, ...
0
votes
1answer
445 views

Converting date field to string using ArcGIS Online?

I want to create a unique ID field for each row of data based on the created_date and OBJECTID. For example, if a sample of data had a created_date on 4/28/17 and an OBJECTID of 1, than I would want ...
3
votes
1answer
220 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 ...
1
vote
1answer
225 views

Select features in statement CASE ELSE or CASE in QGIS 2.10.2

I need to label only US states and canadian provincies Here is my attribute table and my expression Program show that is no error here, but it still don't work. What I'm doing wrong?
1
vote
3answers
968 views

Writing label expression in QGIS to remove end of string?

I am using QGIS 2.18. I have a point shapefile showing ranger stations in a park. The attached image is the field I want to use to label my points. I want to omit "Ranger Station" from showing in ...
2
votes
1answer
732 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/...
1
vote
2answers
2k views

Displaying unit as 'text' within label in QGIS?

When labelling areas in QGIS I can't figure out how to display the unit after the number value from a field. For example the area of my polygon might be 1.23 hectares, which has been calculated ...
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 ...
3
votes
1answer
391 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', '...
0
votes
1answer
247 views

QGIS Atlas Composer : Margin around feature not changing

I try to use an expression to set the margin around a feature in the atlas composer. In documentation, it's explained that it's better to be a double but a string or integer is accepted as an input. ...
1
vote
1answer
338 views

Displaying a symbol label using an expression in MapServer 7

I want to label the numbered roads at all scales with a symbol instead of text. Also, I would like to label the roads using an expression so I could use the symbol corresponding to the road number. ...
3
votes
2answers
220 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 ...
1
vote
1answer
74 views

Label expression problem?

I am mapping the municipalities 911 numbers on our road network and built a simple python expression to find the lowest value between 2 fields. Then it shows that value on the line followed by an ...
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 ...
7
votes
2answers
788 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" = ...
1
vote
1answer
52 views

Is it possible to detect the “composer mode” from witin layer expression

I was wondering if I could create an expression for a layer style that can "detect" the "composer mode" so that it can behave differently when the map is printed (like label priority handling).
4
votes
1answer
190 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 ...
2
votes
2answers
484 views

Writing QGIS field calculator expression? [duplicate]

I have an attribute table with a real data type column named "Volume". Some of these cells have no value, and I want to replace the NULL with a dummy value like -999. In the Field Calculaor I select "...
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 ...
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 ...
1
vote
0answers
113 views

Scale color ramp filtered on common layer columns, in QGIS

I'm creating an atlas in QGIS showing bus lines, tax fare zones, and travel flow lines. I have a layer with bus lines - one feature per bus line. Moreover, I have a layer with travel flow lines - ...
3
votes
0answers
142 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 * @...
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/...
0
votes
1answer
279 views

How to use FindLabel function programmatically using ArcPy?

I want to set the FindLabel function to the labelclass expression using ArcPy. My code is like How To: Label a related table. I don't want to load the function into the expression editor of the label ...
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-...
3
votes
2answers
191 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
155 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 - ...
0
votes
2answers
2k views

How to select features with same values?

How can I select all those features that has exact same values in their attribute field called "X"? I think that the solution could be something like the Countif function in Excel, but I haven't found ...
1
vote
1answer
69 views

PostGIS error with working expression

I'm using OSM-Data via PostGIS (osm2pgsql). To draw a highway with and without bridges or tunnels, I use the following expressions: The highway: "highway" = 'motorway' AND "bridge" IS NOT 'yes' AND ...
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 ...
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 ...
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 ...
11
votes
1answer
882 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 ...
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 ...
0
votes
1answer
424 views

Rotating sld with expression?

I'm trying to rotate an arrow based on an attribute but the arrow is off by 90 degrees. Is there a method for doing a mathematical expression on the attribute within the sld? I've gone over the ...
1
vote
2answers
318 views

QGIS Retrieve field used in data-defined override

I have a point layer in QGIS with an SVG marker. I set the rotation via a data-defined override to the value of one field in the layer. How do I retrieve that field in Python? Not the numeric value ...
1
vote
1answer
230 views

If-then expression and font color in Mapinfo label expressions

How might I obtain the following, other than having two identical tables open to achieve: I would like to label an object using data from two columns from one table? The first half of the label (from ...
2
votes
1answer
195 views

How to use last clicked x/y coordinates in a qgis action?

I created an action (layer properties > actions) that opens an online map. For the action I use this expression to dynamically generate the url of the map. [% ürl" %]/?op=flyTo&cam=[% x($...
1
vote
1answer
742 views

Custom Python Expression Functions (QGIS Tutorial)

I'm having trouble finishing the QGIS tutorial for Using Custom Python Expression Functions: http://www.qgistutorials.com/de/docs/custom_python_functions.html I get to the point where I write the ...
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
0answers
258 views

QGIS use relations in expressions (for symbol and print composer)

I have a shapefile layer a relation linking data from a csv file. This is a one to many relationship where a parcel could have multiple entries from the csv. How do I reference that data in ...
3
votes
2answers
366 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" ...
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" = ...