1

This question already has an answer here:

I need to generate an atlas based on a polygon shapefile, but I'd like to see just what is inside the polygon itself. Maybe with rules that involves other shape's attributes. Any suggestion?

marked as duplicate by whyzar, Andre Silva, Gabriel De Luca, Jochen Schwarze, nmtoken Mar 6 at 15:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You can do as described below. But I strongly recommend to do this only on small(er) datasets, as this will need a lot of calculation. If you want to do this with a bigger dataset, I suggest to first join attributes by location, so you don't need to perform an intersection by expression for every single feature and perform the rule based selection based on the joined attributes.

Create a rule based symbology for your polygon layer using this expression: @atlas_featureid = $id

enter image description here

Now create a rule based symbology on your other layers. Use within() for point layers and intersects() for line and polygon layers: intersects( geometry( get_feature_by_id( 'polygonlayername', @atlas_featureid)),$geometry)

enter image description here

When you now preview your atlas only features are displayed that fall within or intersect with the current atlas polygon feature.

enter image description here

Addition to show surrounding features:

You can also build a buffer around your polygon. Just use this expression for it: intersects( buffer( geometry( get_feature_by_id( 'polygon', @atlas_featureid)),100),$geometry)

100 is the buffer size in meters. Be aware you will need a projected CRS (like UTM) to use this properly. The result:

enter image description here

  • @RicccardoLeuci Updated my answer so surrounding features nearby will also be displayed. – MrXsquared Mar 5 at 16:26
0

If your polygons are square or rectangular, you can size the map extent to suit and select 0% as the margin around the feature.

If you polygons are some other shape (possibly irregular), I would make a new layer that is supersized to cover all your Atlas polygons. Then find the difference between the two layers (which will give you a copy of the supersized polygon but with holes in it where your Atlas polygons are. Add this at the top of your layers and colour it either opaque white or semi transparent (to fade out the surrounding area but still let people see the wider context of the map).

I've used this method both with Atlas and with other maps where I want to focus attention on a specific area.

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