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 > ...
Not sure if this is what you are aiming to:
(1) Select Graduate and choose "values" for Columns.
(2) Set your Color ramp to Blues, perhaps
(3) Click on Symbol: --Change... button to activate Symbol selector
(4) Click on the small Epsilon button (i.e. Data defined override) right to Width
(5) Enter suitable expression something like: (5 - "classes") * ...
The rules seem not to be correct.
The first rule of your example is:
"prcptot" = "prcptot" > 0 AND "p.prcptot" <=0.09
while I guess it should read:
"prcptot" > 0 AND "p.prcptot" <=0.09
Stating "prcptot" = "prcptot"is a tautology, i.e. it gets always evaluated as true.
The fact that it is chained with a > 0 before the AND operator might ...
Right-click on the layer from the Layers Panel and then go to Layer Properties > Labels and choose the label you want to use from the Label with drop-down list (after having selected the Show labels for this layer option).
Then, go to Expression Builder and try to use a CASE WHEN expression. Something like this:
$area > 1600
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")
On the symbology tab of the properties -
For the filter enter "riparian Veg" = 'Yes' AND NOT "Primary" = 'Riparian vegetation management'
capitalization matters - it has to match the field names and attribute values. I just copied what's in your question. If that's not exactly what's in your layer, it won't work.
You use the query ...
Solution for Case 1:
Add two symbol layers to the polygon layer as in the image.
Open Based-on selected points rule, open expression window for Filter.
Go to Function Editor tab and add the following script as function.
from qgis.core import *
from qgis.gui import *
def related_rule_based(layer_name, field1, ...
Below some help to setup rule based labeling from scratch with the new QGIS 3 API
#Configure label settings
settings = QgsPalLayerSettings()
settings.fieldName = 'myFieldName'
textFormat = QgsTextFormat()
#create and append a new rule
root = QgsRuleBasedLabeling.Rule(QgsPalLayerSettings())
rule = ...
The way to get QGIS to put sub-categories into a print legend is to make the sub-categories part of the layer's style. This means that converting your rule-based labels (with colored backgrounds) into part of the symbol style. If this method seems like too much work, see below for a rather hack-y workaround.
Convert your categorized style to a rule-based ...
First, use the method to add rules to renderer and don't use removeChildAt(0) within the method.
After adding the rules, remove the first child of renderer.
Then set layer renderer.
You don't need to define parameters for layer, symbol and renderer in method definition.
You don't need " in expression for field names.
layer = iface.activeLayer()
QGIS uses one apostrophe for python string expression. Concatenating two text fields should be done like this:
"FieldA" + ' ' + "FieldB"
There is a space between the two single apostrophes.
You can also use sa,e principal for integer or decimal values, so long as you use to_string() before the field name.
Furthermore, you do not need to calculate a new ...
There are several ways to achieve this purpose. You can always create rules for labelling, as you suggested, but you could try adding a new column to your file with the label for each desired class.
This way is beneficial compared to creating rules, because the rules will be associated with your project file, and should you move your data elsewhere, you'd ...
Your code works fine. When you want to add a new rule, do not repeat the first 3 lines of code as this creates a new symbol renderer. Just start from
root_rule = renderer.rootRule()
And create your new rule.
I find it easier to use a function like the following:
layer = iface.activeLayer()
symbol = QgsSymbol.defaultSymbol(layer.geometryType())
Okay, your approach points in the right direction, but has the wrong syntax. Please note that you can test rules and that the help in the field calculator/expression builder is worth consulting.
= > instead of >= - QGIS doesn't know how to deal with two operators right after the other.
"5" - things in " always refer to ...
You can use rule based symbology or data defined override.
Since your case is not too complex, I suggest rule based symbology because you will have a nice legend then.
Set it up the following:
In case you want to use data defined override you can do it like this for example:
Use as expression:
When "Nest" is true then 'triangle'
When "Nest" is ...
This script creates a rule based style which refreshes upon the selection of a feature with the logic you described.You only need to enter the layer names below and run it in QGIS.
def __init__(self, polygonLayerName, pointLayerName):
self.polygonLayer = QgsProject.instance().mapLayersByName(polygonLayerName)
The max function doesn't operate across features, just values passed to the function. Eg
Will return 5. There's no function currently available which calculates the maximum value for an attribute across the entire layer.
There's a (totally 100% unsupported) plugin at https://github.com/nyalldawson/topocolour which will add an attribute to your data which handles this.
You'll need to manually download that plugin and copy to your .qgis2/python/plugins folder. It's not available in the plugin repositories.
Well, if i understood your question the answers is this:
You have to use "GEOMETRY (AREA) || GEOMETRY (PERIMETER)".
Step_1 - Layer > Properties > Style > Categorized > E = Insert Expression ( AREA || PERIMETER)> ok... (In this step you can add more Geometry if you have in your table)
Step_2 - classify > apply > Ok...
Step_3 - Legend (On Layers Panel).
You just needed to use "=" instead of "is", surround your field name with "", and replace the () with '' around the offset values, see expression below:
WHEN "name" = 'Brooklyn Bridge' THEN '3.5, 0'
ELSE '-3.5, 0'
Just putting into an answer @iant comment, that solved the problem
If you use
you will display the current entity.
However, if you use
$id <= @atlas_featureid
you will display the current entity + the previous ones in a cumulative way.
You should use a Rule-based renderer. Following your data, something like that:
Click on the + button for adding a rule and then insert the custom expression (as indicated in the red box above).
Remember also to click on the Apply button for applying the style.
In your case you would to represent size of the proportionality with a manual scale... It's not possible by this way as it show here
What you have to do is to define your mathematic function with scale_exp as the size assistant method:
coalesce(scale_exp(Number, 1, 11000, 1, 10, 0.3),0)
Coalesce replace the first value not null by 0.
First param: ...
Yes, either way (making expression with conditions or rule-based symbology) will work fine.
As to the expression in the attached image, you could modify it to:
WHEN "feature" = 11 AND "label" = 'Existing' THEN color_rgb(255,0,0)
WHEN "feature" = 11 AND "label" = 'Proposed' THEN color_rgb(0,255,0)
WHEN "feature" = 11 AND "label" = NULL THEN ...
Instead of creating the leading lines using geometry generator symbology, try using the Callouts tab in the Label options:
You can configure the leading lines with the options shown in the screenshot. It may take some configuring to make them look the same as they were in the geometry generator but doing it this way won't show up in the table of contents or ...
You could also use the following in the Python Console to change all expressions of each rule to $id = $atlasfeatureid:
layer = qgis.utils.iface.activeLayer()
renderer = layer.rendererV2()
for rule in renderer.rootRule().children():
rule.setFilterExpression('$id = $atlasfeatureid')
The above code replaces all expressions entirely. However, if ...