In QGIS Atlas, I can use $id = @atlas_featureid
and $id <> @atlas_featureid
to highlight the label names of my main region (Fig.1: more clear name in the AOI than the outside ones). How can we do similar highlight to the label names other layers or sub-regions, have to link with Atlas setting? E.g. in Fig.2, I want the label names (in English) outside the AOI are transparent than the inside ones.
1 Answer
Imagining your subregion table has a column with the same region code mentioned in it attributes as in one column of the subregion layer, you can add a label rule within "Rule-based Labeling" with the following condition
attribute(@atlas_feature, 'COL_NAME_REGION_CODE_FROM_COVERAGE') = "COL_NAME_REGION_CODE_IN_YOUR_LAYER"
where 'COL_NAME_REGION_CODE_FROM_COVERAGE'
is the column name in your coverage layer feature and code region column in your current subregion layer is "COL_NAME_REGION_CODE_IN_YOUR_LAYER"
You could use also compare geometry from atlas selected feature with the geometry of your subregion layer using something like:
within(point_on_surface($geometry), @atlas_geometry)
It would be quite inefficient to check spatial relationships on the fly each time. It can be a possible solution if no matching column code between your tables, but I prefer adding a column in the subregion layer and fill it once using the same spatial relationship logic instead of calculating it on the fly each time.
-
Thank you Thomas for your quick help. In my Region and Subregion layers have one same column named ADM1_PCODE with the same code, so if I'm not wrong, the statement could be: attribute( @atlas_feature , 'ADM1_PCODE') = "ADM1_PCODE". But it doesn't show any names of Subregion yet.– GISarathJun 27, 2021 at 0:43
-
within(point_on_surface($geometry), @atlas_geometry) doesn't show the label names on the map also.– GISarathJun 27, 2021 at 0:51
-
-
Where did you set the expression? In your subregion layer labels panel properties? Jun 27, 2021 at 1:04
-
It works now. Sorry, it's my mistake to not select the field name in Value field. Thank you very much.– GISarathJun 27, 2021 at 1:37