1

I am using QGIS 3.28.

Use-case: I have a layer named: map_1, which is a map of many regions. The regions are identified with City_id. To distinguish the regions by their ID's, I first categorized them by random colors, and second added a label based on the field "City_id". See attached screenshots.

A sample of the map, showing the categorized regions of the layer, with their labels

Problem: Since some regions are interfering with some others and/or are too tiny to be distinguished, it's hard to know the relevant regions for some labels.

For this reason, I thought of categorizing the labels using the same array of colors that was used for the parent layer. In other words, I want each label (i.e. City_id) to be colored with the same color as its referred region. Had I a small number of regions, I'd do this manually one by one, using the Rule-based method, but this unfortunately isn't the case, as I have several maps, with a total of ~3000 regions.

The regions are categorized by the field: City_id, using random colors I guess this is very feasible, if only I could get the code of the categorization that was automatically generated for the layer and apply it the same in the Rule-based labeling. However, there might probably be much more simple/efficient methods to solve my problem.

Any insight?

I thought of categorizing the labels using Rule-based Labeling

Image demonstrating the solution provided by @Mr_Yum below:

I'm adding the screenshot here, since it can't be added elsewhere (i.e. in a comment): Having tried the @symbol_color, it worked. P.S. I had vewed it before, but I didn't think it would work, because I saw in the description (to the right side): current value: #000000 (as seen in the screenshot) and I thought I should use some formula with python to make it work, so I didn't click OK! Image demonstrating the solution  using @symbol_color If anyone may add an explanation of how does @symbol_color work, please do to enrich this issue.

1 Answer 1

2

You can use the variable @symbol_color in the buffer color rule.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.