12

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 > Placement > geometry generator and select geometry type as linestring: In the expression box (red arrow in image above), to place your label at the start of the line, ...


8

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


7

If you use Single labels instead of rule-based, you could concatenate more than one field using ||. Couple this with an if statement, you could try the following expression: if("BBT_CODE" is not NULL, "Bio_Code" || ' / ' || "BBT_CODE", "Bio_Code")


7

Another way, using the same method as presented above by Joseph, with a slightly shorter code: if(LABEL % 10 = 5,"","LABEL") When the remainder of dividing by 10 is 5 (so 5, 15, 25...) it won't show the point.


7

I think you will need a custom function to do this, the following seems to work though I haven't tested it extensively. from qgis.core import * from qgis.gui import * from qgis.utils import iface @qgsfunction(args='auto', group='Custom') def getCrsDescription(feature, parent): """ Returns the description text of the project CRS <h2>...


7

You need to use a nested replace() function such as replace(replace('£10,000.00','£',''),',','') You can nest as many replace() as you want.


7

You can do both replacements using a single function call: 1) using regex_replace, where you would look for the two characters of interest (inside square brackets): regexp_replace("field_name",'[£,]','') or 2) the map variant of replace, where the map is a series of key-value, the key being the string being searched for and the value being the replacement ...


6

If you data is as organised as you say, creating the "tree column" with following expression for the field calculator should work: CASE WHEN $id%3=0 THEN 'Cashew' WHEN $id%3=1 THEN 'Baobab' ELSE 'Banana' END Short explanation: This checks whether the feature's ID is divisible by 3, and if not, what rest (% is the modulo-operator) is left, then assigns the ...


6

You could replace '.qgs' by nothing '' in your expression: replace( @project_filename , '.qgs', '') As J.R pointed out, you could also select the whole filename, minus the last 4 characters substr( @project_filename ,1,-4)


6

So you want to sum the "Abundance" grouped by "SiteNum" and place the results in another_table with a common ID? The clue is in relation_aggregate(). More info: https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/expression.html#aggregates-functions and in the expression-builder First, you have to define a relation: Project > properties >...


6

I'm not familiar with VB, but the following Python may do what you're after (with the 'Advanced' checkbox ON, and assuming a Shapefile where NULLs are not possible): def FindLabel ( [conductor_a], [conductor_b], [conductor_c] ): if len([conductor_a]): return [conductor_a] elif len([conductor_b]): return [conductor_b] else: ...


6

you can make your own expression for that with the function editor: and then use the new expression in the layout: with the following code: from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def layoutid(layoutname, feature, parent): """ Returns a unique layout id. <h2>Example usage:</h2> &...


5

What a shame the to_interval expression treats each month as 30 days! Here's an ugly expression which will do what you want: to_date(concat(year("date")+floor((month("date")+"months"-1)/12), '-', right('0' || ((month("date")+"months"-1)%12+1) , 2),'-', right('0' || day("date"),2))) It breaks the date down into year, month and day, then uses ...


5

Try something like: u'\u0305'.join([KOM_KOD]) See: Make overlines in python


5

Have you tried something like : CASE WHEN "Surface" >= 30000 THEN 4 WHEN "Surface" < 30000 AND "Surface" >= 10000 THEN 3 WHEN "Surface" < 10000 AND "Surface" >= 5000 THEN 1 ELSE 0 END


5

The functions to extract temporal "parts" year(), month(), week(), day(), hour(), minute() and second() have a secondary function on intervals where they actually calculate the number of years, months, weeks and so on. For example day( to_date('2019-12-31') - to_date('2019-01-01') ) returns 364 as there are that many days in that time interval. ...


5

With credit to Vince, the correct expression to use in this case was: concatenate( to_string( "ID" ),group_by:="X, Y", concatenator:='|')


5

..I got it! I use this expression for a composer item label with 'insert expression': aggregate(layer:='Corridors_86ef2ea9_d1a1_4d9f_9735_7b7b2fb54cb2', aggregate:='concatenate', expression:="Name", filter:=within($geometry, map_get( item_variables('Main Map'), 'map_extent')), concatenator:=', ') Works like a charm:)


5

You can achieve that using an SQL Query in the DB Manager of QGIS. You choose Database / Database Manager / Database Manager then Virtual Layers / Qgis Layers you can then try queries like the following : select ID from layer1 where ID not in (select ID from layer2) Depending on the size of your tables it can be a bit time consuming ...


5

How about this ? array_find(generate_series(1,5),"ID")>0


5

Open user profile folder ("Settings > User profiles > default"). Goto /python/plugins/refFunctions. Open refFunctions.py. Go to geomintersects function definition. Change 100000 in if count < 100000: to a value that you desire. You need to do same process for the other functions, if you want to use them.


5

With a simple test data of 2 locations ("group" in this case) with 6 points each; Create a new field to count each type at each location, for instance type_A by: count( "type", group_by:= "group", filter:= "type"='A') Here group_by:= part defines the group to aggregate, while the filter:= extracts the data matching with the condition "type"='A'. Repeat ...


5

For this you can use the with_variable function with an if conditional. Basically you always create the line but you only return it from the expression if it is longer than your threshold. Here I used a threshold of 10000 units: with_variable( 'line', make_line( make_point($x,$y), -- the feature's geometry make_point("x","y") -- ...


5

Seems to be an error in the documentation. The syntax must be: is_selected([layer=current layer][, feature=current feature]). Try: is_selected('Schools', get_feature('Schools', 'INST_NO', "schoolid")) Source: https://github.com/qgis/QGIS-Documentation/issues/1475


4

CASE WHEN array_contains(array_distinct(array_agg("MH1")), "MH#") OR array_contains(array_distinct(array_agg("MH2")), "MH#") THEN color_rgb(255,0,0) ELSE color_rgb(255,255,0) END


4

Open the field calculator, select the function editor and make the content look like: from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def tree(value1, feature, parent): trees=['Cashew','Baobab','Banana'] idx=value1%(len(trees)-1) return(trees[idx]) Press "Save and load functions" then in the Expression tab,...


4

If in your field, the number in the code varies from 1 to 9 (only one digit), you can use the following code : CASE WHEN to_int(right("my_code_field", 1)) = 6 THEN 0 WHEN to_int(right("my_code_field", 1)) > 6 THEN Null ELSE to_int(right("my_code_field", 1)) END For explanations, I use the conditional function CASE WHEN condition THEN result ELSE ...


4

You are using the wrong quotes. Try '' instead of "". E.g. if( floor("area") = 0, '',floor("area")||'m²') Double quotes " refer to fields. In your case to the field " " (whitepsace), which most likely does not exist. Single quotes ' refer to strings. If you want it to be just empty, there is no need to add a whitespace. Another suggestion / alternative: ...


4

If the column is a virtual field it's easy : just open the layer properties, go to the "Source Field" tab and look for the "Comment" column. The expression is here and you can edit it (or simply view it better) by clicking the Ɛ. If it's not a virtual field, I don't know of any way to recover the expression as only the resulting values are stored in the ...


4

If you get too many features in such an expression, the problem is often a stray 'or'. To me it looks as if you have got everything right here, but you are asking for quite a lot... are you sure you are not querying for the entire data set? Do you also get the barriers and waterways? If so, try to remove the "is null" part and see what is happening. Also, ...


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