I have an area which is divided into several zones the borders of which I have defined as separate layers. The layers are defined by sql queries on a postgis table of line segments joined with a table that says which segments are part of which zone boundaries.

What I want to do is produce a set of maps where each map is a zoom to layer extent for each zone and which has standard header, legend and scale (which will preferably vary with the zone but could be fixed across all maps).

My first attempt was to get a new composer for each map -- that worked but was rather tedious. Next I tried producing one map and printing it and then deleting the map frame and going into qgis to zoom to the next layer extent and make the boundary visible then hopping back into the composer to load it in. This worked more or less. Map was fine, legend was OK because it was the same for all the maps and the zone name was easy to edit but the scale needed to be deleted and set up again for each map.

Next I looked at Atlas Generation. The manual seems to assume that you know how it works and all you need is a reminder about the details (like so many software manuals ;) It seems to assume that you have something that you are iterating over but I can't see how to make it work -- there is nothing to iterate over to get the layers.

Any suggestions welcome!! :)


  • Do they have to be in different layers? – Nathan W Nov 5 '13 at 5:03
  • The catch, I suspect, is that I want each map to have just the boarder of the specified zone visible. They are weed surveillance zones, each zone has a team of volunteers and we want to have a map for each zone which details the boundaries and surveillance tracks. now if I could iterate an sql query that would do nicely;) – Russell Fulton Nov 5 '13 at 5:11
  • 1
    In order to use Atlas you need to have it all in a single layer. Hiding all other features expect the active Atlas one is a opened feature request. – Nathan W Nov 5 '13 at 5:14
  • That is what I thought. Thanks for confirming that. I first thought templates would do most of what I wanted but they are just saved snapshots. So it looks as if I am stuck with doing this more or less from scratch for each map I want to produce. – Russell Fulton Nov 5 '13 at 5:25
  • Do you know python? If so this is fairly easy to achieve using pyqgis. – James S Nov 5 '13 at 7:30

In QGIS 2.2 (or now in nightly builds) there is a feature that allows you to highlight the current feature. This can be used to mask the other zones out as you iterate over them. You can't really hide the other features but you can use this to create a black out layer which might look a bit ugly but will have the same effect.

What you need is:

  • Nightly QGIS, or 2.2 when it's released
  • A layer with each zone as polygons
  • A composer layout

I only have suburbs so I'll just use that for the example but you'll get the idea

Create your composer layout and enable the Atlas feature, selecting your zones layer:

enter image description here

If you add an label with text like:

Current Zone: [% "ZoneName" %]

It will fill in the current zones name. Tip: Anything inside [% %] is an expression.

Switch back to your map and use the rule based rendering style on your zone

enter image description here

$id =  $currentfeature 

Is the rule to style the current active atlas feature. e.g the id of the check feature is the same as the atlas feature. Make sure this layer is right at the top so it hides the others

The ELSE rule is everything else (new in 2.2). Apply the style

enter image description here

Jump back into the print composer and print a run off your maps.

This will be the result

enter image description here

With some setup you can do little insert maps, etc, with this new feature

enter image description here

  • Thanks again Nathan, good try but in my case my features are not polygons. They are multilines which represent tracks that make up the 'surveillance zone'. – Russell Fulton Nov 12 '13 at 7:42
  • It will work the same. Or at least you might have to convert them to polygons for this case. – Nathan W Nov 12 '13 at 8:37
  • 7
    FYI, updated in QGIS 2.4, the rule filter should be $id = $atlasfeatureid – James N Jul 18 '14 at 8:25
  • 3
    In QGIS 2.8, you can achieve a much better result by using the 'Inverted Polygon' render with a white fill and a 'Rule-based' sub-renderer with the $id = $atlasfeatureid rule – spatialthoughts Apr 24 '15 at 5:10
  • In 2.8.1 should I have the option of an Inverted Polygon when I am in the rule based dialogue box? I can see that Shapeburst is an option but Inverted is not. Am I looking in the wrong place? – Johanna May 25 '15 at 2:18

As James N said, latest QGIS versions use:

$id = $atlasfeatureid

I would like to add you can easily restyle everything outside of your atlasfeature (including areas outside the atlas shapefile) by selecting inverted polygons after creating the rule:

enter image description here

For example if you want to show only a certain province and not only remove neighbouring provinces but also neigbouring areas outside your country (and shapefile).

  • in QGIS 3 it is @atlas_featureid – mbernasocchi Oct 25 '18 at 13:14

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.