2

I have a LineString layer that has geometries generated to draw boxes around them with an additional 10% of the line length added to each end.

I then want to use print layout and set the map extents as the bounds for geometries generated. Is there a way to do this?

0

1 Answer 1

3

Easy option

There is a Margin around features function in the atlas settings that you could use.


Solution based on Geometry generator

If you indeed want to use the extent of a layer resulting by geometry expression, proceed as follows:

  1. In the layer containing the lines, create a virtual field using field calculator to create a field named xmin with this expression: x_min (bounds ( [your_geometry_expression] ))

    • Be sure to replace [your_geometry_expression] with the expression that creates the extended lines.

    • If you create virtual fields, you can add, delete, modify the lines and still get correct results.

  2. Repeat step 1 for xmax, ymin and ymax.

  3. Go to the Layour manager -> Item Properties of the map/atlas -> Extents and use the fields created in steps 1 and 2 as input for data driven override.

Screenshot

Extents -> Data driven override (ɛ icon) in red box; below, highlighted in yellow: setting for Margin around feature (here set to 0). As you see, the extent from the extended line (red) is used, not the extent of the initial line (black): 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.