I try to use an expression to set the margin around a feature in the atlas composer.

In documentation, it's explained that it's better to be a double but a string or integer is accepted as an input.

I use this expression that returns a double:

bounds_height( $geometry )/ bounds_height(  geometry( get_feature( 'allin1', 'id_ws_int', attribute(  @atlas_feature  ,  'id_ws_int' )  ))) *100+100

But nothing changes. Tried with to_string and to_int but same result.

Tested in 2.14.12 and 2.18.4

No bug reported found.

  • Please check the expression results, perhaps using a label element in the composer. It should be e. g. 100.0 for 100 % margin. – Redoute Mar 24 '17 at 7:56
  • Yes i checked with float and string concat %, 0.0 , 0,0 etc – jlSta Mar 24 '17 at 20:57

I tested your szenario in 2.18.4 and it works, see images below.

I choosed to have features in allin1 being smaller than in the atlas layer, so that different margins will have a visible impact. In the first picture the feature is 8.19 times higher than allin1, so your formula calculates to 919. In the second picture it is factor 2.72, result 372.

If allin1 features are bigger than the atlas features, results are between 100 and 200, which may make no eye-catching difference. So I guess your formula is not what you want and you didn't check the results.

I simplified attribute( @atlas_feature , 'id_ws_int' ) to "id_ws_int"; but both work.

margin 919 % margin 372 %

  • OK, i tested directly with numbers and it works. You are right it s because the zoom variation is not visible sometimes. Yhis mistakes comes from the percentage field is not up2date – jlSta Mar 27 '17 at 9:10

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.