0

I've created a workspace template for QGIS for the projects we work on at my company. I want to create layers that work with the workspace template for our projects. However, the one thing I'm struggling with is finding a way to get the Map to set its extent to the 'Site Boundary' Layer by default.

Anyone got any ideas?

Ideally, if there's a way to get it to set its extent to 'Site Boundary' plus 1000m either side, that'd be even better (with the ability still to go in and change the scale afterwards/move the centre focus of the map around if necessary once the layout is loaded), but at this stage I'd be willing to settle for even just getting it to automatically centre the map on the Site Boundary when loaded.

1
  • What is your site boundary and how is it defined ? You should try using the map extent properties in your layout and set them by expression to center it around the site boundary at a given scale, or +/- some margin
    – Kasper
    Commented May 17 at 6:07

1 Answer 1

0

This answer might be adapted depending on how your Site Boundary is defined.

One generic way to do what you are asking for: programatically define the Layout map Extent based on your data layer(s) boundaries.

Set your Map item Extent properties like this respectively for X min, Y min, X max, Y max: xmin(collect_geometries(aggregate('Lines','array_agg',$geometry)))-500 ymin(collect_geometries(aggregate('Lines','array_agg',$geometry)))-500 xmax(collect_geometries(aggregate('Lines','array_agg',$geometry)))+500 ymax(collect_geometries(aggregate('Lines','array_agg',$geometry)))+500

Replace 'Lines' by the name of the layer you want to use to control the extent Replace 500 by the margin you want to add (value depends on the margin itself in CRS units)

enter image description here

With a different layer content, the extent changes automatically.

enter image description here

Your Answer

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

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