3

In the layout view (QGIS), I selected the rectangle in the add shape to clip my image (map). However, when overlaying the grid, the edges of the grid extend beyond the clipped image. (appears to cover the "original image")

How do I clip the grid to the extent of the "clipped" image?

enter image description here

2
  • I want the grid + coordinates to clip to the extent of the map and not the blank (white) area. Need help to do that! Jun 8 at 1:34
  • Can you explain the purpose of the rectangle? I normally just add a Map to a Layout, and then set the Grid on the Map. The Grid automatically is clipped to the extent of the Map. Jun 8 at 8:38

1 Answer 1

3

First of all set the extent, to do this set a expression in each of this parameters (X min, Y min, X max and Y max) in the Extents menu of the map properties.

1

click the icon (2) in front of each of the extent parameters, select the Edit... option in the popup, set the following expressions in each parameter respectively.

X min: x_min(layer_property('layer name/id', 'extent'))
Y min: y_min(layer_property('layer name/id', 'extent'))
X max: x_max(layer_property('layer name/id', 'extent'))
Y max: y_max(layer_property('layer name/id', 'extent'))

remember to replace layer name/id with your layer name.

Now in the Position and Size menu of the map properties set the following expressions (the same way we set the expressions of the extent) to the properties Width and Height

3

Width:

with_variable(
    'extent',
    layer_property('layer name/id', 'extent'),
    150 / array_max(array( -- replace here "150" with the size in mm of the longest side
        x_max(@extent) - x_min(@extent),
        y_max(@extent) - y_min(@extent)
    )) * (x_max(@extent) - x_min(@extent))
)

Height:

with_variable(
    'extent',
    layer_property('layer name/id', 'extent'),
    150 / array_max(array( -- replace here "150" with the size in mm of the longest side
        x_max(@extent) - x_min(@extent),
        y_max(@extent) - y_min(@extent)
    )) * (y_max(@extent) - y_min(@extent))
)

again, set the correct layer name in layer name/id

Your Answer

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

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