37

You just gotta use the LIKE operator. For example, "TITLE" LIKE '%MINERAL CLAIM%' The % symbol acts like a wildcard. LIKE is case-sensitive, whereas ILIKE is not.


17

You can use data defined properties for this. Use the style tab on the layer properties and click the expression button to the right of the color. In there you can use the function color_rgba( red, green, blue, alpha ) to create the color. All values need to be between 0 and 255. Example: color_rgba( 255, 0, 0, ( 1 - "transparency" ) * 255 ) This will ...


16

Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string. So in your first case you get NULL because you don't have an attribute called something.


15

Since the number of characters is same, you can use substr() function on a new field as in the following expression: substr( "Location" ,17,6) In the above example I used Path instead of Location


13

As a follow up to Matthias' answer, in QGIS >= 2.12 you can use a data defined fill color with the expression: set_color_part(@value, 'alpha', ( 1 - "transparency" ) * 255 ) What this expression does is takes the original polygon color (@value) , and replaces the alpha channel (opacity) with the value calculated from the field). This means you can set ...


12

In QGIS >= 2.14 you can use the symbol_color variable. Eg, set a data defined override for your label color to the expression @symbol_color


12

Your observation is correct, The Query Builder does not use the same syntax as the rest of QGIS. Throughout QGIS, the syntax is based on QGIS Expressions a customized SQL dialect. This is portable between almost all parts of QGIS where you can enter a filter, calculate a value... This syntax is parsed and evaluated directly in QGIS (and parts of it may be ...


12

2020 Oct update - label placement at start/end of lines or with a given offset is now be an inbuilt feature of QGIS 3.16 ! Link shows it in action. QGIS 3.8 to 3.14 Consider using the geometry generator option under label placement, and generate just a tiny subsection of your linestring at the beginning or end to place the label on. First go to Labels > ...


11

This can be done using the Processing Graphical Modeler to set up a custom chain. Here's a pic: From left to right we have three inputs - the tree layer (a Vector Layer Input Object), the buffer size (a Numeric Input) and the tree height (a String Input). The tree layer is then selected by its height attribute. The selected trees are then buffered by the ...


11

Inserting new fields with the field calculator and the expression $x and $y on the layer with your centroids should do the job. If you use the polygon layer of your lakes, you might include there lat/lon in the attribute table directly with x(centroid($geometry)) resp. y(centroid($geometry)). If your layer is not in EPSG 4326, you can use this expression to ...


11

You can use the new overlay expressions, available since QGIS version 3.16, see Visual changelog. By the way: I'm not sure what you mean that you have "a multi-polygon file with polygons and points", that does not make sense to me, so maybe be more precise. Likewise, you did not include any information how the colors in layer 1 are defined. But ...


10

Underdark has composed some nice examples for labeling expressions: Easier Conditional Labels in QGIS Here are some helpful links for querying: Query Attributes Working with Attribute Table - Basic Queries If you are interested in coding then you can start with this resource: pyQGIS Developer Cookbook


10

It should be "First field" || ' ' || "Second field" || is string concatenation operator. Use Single quotes for Space, Double Quotes are for Field.


10

If your original field is a string-type field, you can update it instead of creating a new field. Use the Field Calculator to update an existing field Check the box next to "Update existing field" Select "oldfield" from the dropdown menu Use this expression* concat("oldfield", 'm') If your original field type is numerical, you can't add text to it. ...


10

Here is the answer directly from QGIS help: column name "column name" → Value of the field column name, take care to not be confused with simple quote, see below 'string' → a string value, take care to not be confused with double quote, see above


10

If the string should contain lowercase, use this expression in 'Expression Dialog' if(regexp_match("test",'([a-zäöüß]+)'),1,0) for uppercase change '([a-zäöüß]+)' into '([A-ZÄÖÜ]+)'. Otherwise, I would recommend writing a small script as was suggested by @MortenSickel. Personally for me it does not make sense writing a statement if(regexp_match(upper("...


10

You can use regular expressions like this: regexp_substr("yourtextfield",'[^;]*') To match more characters than ; you can just add it to this expression like: regexp_substr("yourtextfield",'[^;,]*') which will return all values before ; or , characters.


9

Can it be done. Of couse with QGIS the answer is normally yes. Lets take our vector layer with some normal labels and symbols: Now add a data defined color for the buffer: Click on Edit and select the function editor. Click new file and give it a name (called mine colorfuncs) Paste the following code from qgis.core import * from qgis.gui import * @...


9

So the way QGIS handles NULL when you join strings is that it will convert the result to NULL if any part is NULL (yes I know it's on going debate on if it should or not) Here is how you handle that using the concat function: concat( "genus_species", '\n', "english_species", '\n', to_string("planted_year") The concat function will convert NULL to empty ...


9

Try this if you want to Select by Expression GetUtmZone() = '40N' If you just need to get the return value from the function you can just do GetUtmZone() The $ prefix used to be used for functions that took no arguments however that is no longer used in later versions, the version in the tutorial is a older QGIS version that still supported that format.


9

Assuming your rows are already sorted, you just have to create a new integer field with the expression: ($rownum + 1) / 3


9

Assuming maintenance_ID field is already given, I would use Add autoincremental field tool (in Processing Toolbox > Vector table) to prepare a temporary field, then put them together. (1) Start Add autoincremental field and select maintenance_ID as the Group value. (2) The tool will return a new layer Incremented with a new AUTO field. (3) Use the Field ...


9

There is a way to display the coordinates... though not as a label. One can add style with geometry generator to extract the vertices, then add a font marker style that will be overridden to display the vertices coordinates.. add the vertices Add a style of type geometry generator, geometry type point computed with the expression nodes_to_points( $geometry)...


8

You can do something like this (steps explained as comments): #Get the layer reference. In this example I'll use the current layer: cLayer = iface.activeLayer() #Build the expression. STATE and CITY are field names; # state and city represent the values from your combo boxes expr = QgsExpression( "\"STATE\"='{}' AND \"CITY\"='{}'".format( state, city ) ) ...


8

Some useful stuff here for 1.8 and older http://hub.qgis.org/projects/quantum-gis/wiki/How_do_I_do_that_in_QGIS http://hub.qgis.org/wiki/quantum-gis/Calculating_field_values http://hub.qgis.org/wiki/quantum-gis/List_of_Field_Calculator_Functions


8

Try with concat('http://www.example.com/img/',"filename",'.jpg'), replace the .jpg with the appropriate extension if all of your images are the same type. Or concat('http://www.sylve.ch/docs/',"filename") if the extension .jpg or else is included in your name's file.


8

As starting point for studying I would use the QGIS Cookbook. For further reading with additional examples look at the books Joseph suggests in his answer. As for your specific problem I would suggest string substitution like it = vl.getFeatures( QgsFeatureRequest().setFilterExpression ( u'"field_name" = {0}'.format(values[j])) )


8

You can use the floor function in your expression, like this: floor($id /24) IN (1,3,5,7,9,11,13,15,17,19,21) On a sample grid I've obtained this result with my own numbers (my grid has 13 columns per row): I've used: floor($id/13) IN (1,3,5,7,9) So, in general: floor($id / number_of_columns) IN (1, 3, 5, ..., 2*number_of_rows_to_be_selected - 1) To ...


8

Layer filters don't use QGIS expressions, and are instead handed directly off to the underlying data provider. So, for instance, a filter on a postgis layer is passed to postgres to evaluate, and accordingly must use postgres syntax and functions. This means QGIS expressions functions and features like variables don't work in layer filters.


8

You only need to include CASE at the beginning and END at the end of your expression. So it should read: CASE WHEN "PROP_VALUE" IS 50 THEN '50' WHEN "PROP_VALUE" IS 100 THEN '100' ... END As @Midavalo mentioned, you could also use the modulo operator: CASE WHEN "PROP_VALUE" % 50 = 0 THEN "PROP_VALUE" END


Only top voted, non community-wiki answers of a minimum length are eligible