2

I have layer in QGIS that I want to style using SVG symbols.

I want the SVGs to increase in size when zooming in the map. I can solve this by using map units instead of millimeters.

Though, I don't want the symbols to increase 1:1.

Say, I want the symbol to be 75 map units at zoom level 1:50.000 but only 37.5 map units at zoom level 1:3.000.

I guess that using QGIS Expressions here is key, but I can't work out a proper mathematic formula that fixes my problem.

Can I use the scale_exp function in the Expression string builder in QGIS?

Can anybody help out?

3

You can try this formula applied on Data Defined Override near the size of the symbol and apply map units as in your case:

enter image description here

Case 
When @map_scale <=3000 then 37.5
When @map_scale > 3000 and @map_scale < 50000 then 50
when @map_scale >= 50000 then 75
end

You may need to define a symbol size between the 3000 and 50000 scales

The size of SVG symbol will be adjusted based on the map scale of the view not the layout scale.

  • Thank you so much for your time. This is maybe not the ideal solution, but still a great solution :-). – kwiwe Oct 30 '18 at 8:37
  • @kwiwe You are welcome. If the answer solved your problem, please accept it so that it can help others. :) – ahmadhanb Oct 30 '18 at 8:45
2

This expression works only within the set input range (3,000 - 50,000), but you will get the idea.

scale_exp("value", 3000, 50000, 37.5, 75, 0.24638)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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