1

I am looking for a method to vary the map scale of a QGIS layout according to the visibility of a layer.

The output should show the minimum scale at which the layer can be seen in the layout from a range of predefined scales (e.g. 1:1000, 1:2500 etc.).

I would like the method to work with the QGIS Atlas so that the output can be exported efficiently.

As an example, the images below show the layout at 1:1000 (site boundary only), 1:2500 (site boundary and surface water) and 1:5000 (site boundary and surface water). I would like the layout scale to automatically adjust depending on the minimum scale at which surface water can be seen from a range of predefined scales. So in this case, produce a layout at 1:2500 and not 1:1000 or 1:5000.

Example

  • 2
    Are you looking for something like this: gis.stackexchange.com/questions/253909/…? – ahmadhanb Sep 18 at 12:00
  • It doesn't quite do what I am after. In the first instance the expression would need to be able to identify the visibility of the layer rather than the scale of the map. – R.B Sep 18 at 12:47
  • 2
    Please provide additional details to your question like screenshot to make everything clear. – ahmadhanb Sep 18 at 13:03
  • Please see update, hopefully that's more clear. – R.B Sep 18 at 13:34
  • you could probably use a data-defined setting, with an expression based on the bounding box of the current atlas feature – csk Sep 20 at 16:36
1

Calculate the distance to the closest surface water then use this distance to determine the appropriate scale.

  • To calculate the distance to the closest water add a field (it doesn't seem to work with virtual field) in your site boundary layer and use :

    geomnearest('SURFACE_WATER_LAYER_NAME','$distance')

Then use this field to set the scale in your layout with an expression like this if you want to use a few scale:

CASE
WHEN "DISTANCE" < 500 THEN '1000'
WHEN "DISTANCE" > 5000 THEN '10000'
ELSE '5000'
END

where "DISTANCE" is your calculated field (adjust the numerical value to your need)

Or if you want something that give the biggest possible scale set the scale with :

"DISTANCE" / x

where "DISTANCE" is your calculated field and x is half of the shortest mesure of your map element en meter (so if you map element is 10 by 20 centimeter then x=0.05)

  • Thank you. Unfortunately the surface water layer name is too large and returns an Eval Error: error: too many features to compare. – R.B Sep 19 at 8:12
  • @RyanBell maybe you could simplify or use a subset of your surface water layer – J.R Sep 19 at 9:33
  • I don't think simplify will help as the number of features will remain the same. I will explore splitting the data up. – R.B Sep 19 at 10:31

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.