23

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 ...


14

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.


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 ...


11

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 ...


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 ...


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

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


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


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

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


8

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 * @...


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

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 ...


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

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


7

If there is only need to select 'all permian lithologies' and no other conditions - you can use syntax like this: "GEOLHIST" LIKE '%Permian%' This should select all occurencess of 'Permian' word. This will not work with 'permian' probably. But you can change to '%ermian' thought.


7

It is my understanding you cannot directly perform spatial queries in the Defintion Query tab. However because ESRI offers a calculate geometry option for common shapefile geometry calculations and automatically calculates area for feature classes, you can do a psuedo spatial query on a field containing the value of area for each polygon. For shapefiles the ...


7

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])) )


7

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


7

Unicode has some superscript and subscript characters in it as described on Wikipedia Here are two custom functions that can be entered in the QGIS Python Function Editor that superscript or subscript the digits in strings passed to them: Superscript @qgsfunction(args='auto', group='Custom') def supscr_num(inputText, feature, parent): """ Converts any ...


7

Please follow the python syntax-Just check if hike is in the Name. Below should work def FindLabel ([Name]): if 'hike' in [Name]: return [Name] But if you need to label only Name does not contain hike use below- def FindLabel ([Name]): if 'hike' not in [Name]: return [Name] 'LIKE' is an SQL operator that may be used with wildcards ...


7

A value in one (or both) of your fields is a number, and python is trying to add it due to the + symbol, or alternatively it could be a value that can't be handled in its current form. Either way you'll need to tell python that it's a string. It is currently trying to use the value as unicode and it needs a string. Using the Python Parser you need to use: ...


7

The easiest way is to modify the expression used for the label to be: replace( "NAME" , 'District', '') Or if you are using BoundaryLine then I recommend regexp_replace( "NAME" , 'District.*$', '') to deal with districts like 'Allerdale District (B)'. Infact for completeness I use: wordwrap( replace( regexp_replace( "NAME" , 'District.*$|...


7

You need to double escape the brackets (this applies to any kind of bracket): strpos('This {is} s a test', '\\{is\\}') Tested on QGIS 2.18.7.


7

You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well): Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties function on the right, you may access layer ...


6

Label expressions are similar to field calculator: you don't need to use a for loop as the expression is already applied to every feature. Also, you'll get an error with your code as per the help: Field values are automatically cast to text strings. Therefore, if you wish to use a numeric value in an arithmetic operation, or when making a comparison, ...


6

Just tested (QGIS 2.8). It works if you add a END statement at the end, like that: CASE WHEN "dBM" <= 0 THEN '255,0,0' WHEN "dBM" > 0 AND "dBM" <= 20 THEN '255,255,0' ELSE '0,255,0' END


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