6

I've got 30 contour datasets that all sit over the same extent. Each contour set is in its own file. I also have 30 extent polygons for each contour set as a separate file.

Can I use Atlas to generate a series of maps - each displaying a 'pair' of datasets - ie. contours and extent for each pair over the same extent?

Everything I've read indicates that you can loop through features in a layer with Atlas, but not through multiple layers. Could I work around this by adding a 'layer display list' as an attribute of the coverage layer?

Maybe with a python script?


Update:

This is going back to a previous question from a few years ago that I asked and didn't find a solution for. QGIS has advanced a few versions since then - so I'm hoping there is either an updated solution, or someone could provide guidance to develop a script.

Advanced warning - I'm a geologist - layers of rock are how I think! :-)

I have a project area for which I want to produce a series of maps (an atlas). Each map will cover exactly the same extent, but will show properties for a different layer of rock. In this example - contours of the depth to the top of 50 different rock layers.

The desired output would be 50 maps, same extent, different layer (or layer set) displayed

To add more complexity - I'd like to add 'sets' of layers. Rock layer 1 also has unique shapefiles showing the extent polygon layer and also a label_point layer.

Current Method

I've tried merging all the contour layers into one shapefile and using this as the Atlas coverage layer. This method doesn't quite produce the desired result because:

  • I can't filter the combined layer to only show one layer (not one feature) at a time.
  • I can filter using this rule based style expression on the combined layer! (where unit is the rock layer name):

attribute($currentfeature , 'unit') = attribute(@atlas_feature, 'unit')

  • Critical issue - I get one page per individual contour (ie. one per feature - so hundreds of pages per rock layer). I can't work out how to filter so I only get one page per rock layer (or if that is possible).
  • I can't merge the different 'sets' (points, polylines, polygons). Workaround - I could merge and filter based on geometry type - same as above.
  • Merging 50 input files into one master shapefile seems a bit redundant - surely one more code loop could negate the need for this? Workaround - use the processing framework to combine input files.
  • So yo want a two maps on the page using different layer extants? – Nathan W Nov 28 '13 at 2:27
  • Desired output would be 30 maps, same extent, different contour and contour extent datasets on each map – tomtomnz Nov 28 '13 at 3:56
  • 1
    Could you not just use the contour extents? – Nathan W Nov 28 '13 at 4:12
  • 1
    Or could you upload a quick picture of what you need. – Nathan W Nov 28 '13 at 4:12
  • Is there a reason for creating a new question rather than updating your previous, unresolved one? – underdark Jan 13 '16 at 19:15
5

Since QGIS 2.12, with the introduction of data-defined properties on the "lock layers for map" option, in the map item properties, you can do what you seek. You just need to create the right coverage layer, with the information of the extents, but also of the layers to "print".

Create the layer presets

You can "save" the current state (visible or not visible) of your layers as presets. Just create the desired combination and press the eye icon on the layers panel, and choose "add preset".

Basically, you will have to create a preset for each contour, with that layer visible (paired with other layers if you like). This will be your "set of layers".

Give your preset memorable names, or else just opt for some kind of a sequence.

Creating the coverage layer.

Now you will have to create a polygon layer with all the possible combinations between the extents polygons, and all the presets. That means you will end up with some redundancy. You will have to replicate each extent polygon for each preset. Something like this:

polygon 1, preset a polygon 1, preset b ... polygon 50, preset a polygon 50, preset b

You can do this manually with copy paste, or else create some kind of script, but I would say your best and easier way would be using Spatialite or Postgis database. Just import you polygons extents there, and create a new non-spatial table with all presets names. Then, create a view that returns all the combinations.

SELECT f.*, g.preset_name
FROM polygons_extent as f, presets as g

Making it work

Add the new layer or view to QGIS, use it as coverage layer in atlas settings, and use the preset_name attribute in data-defined properties on the "lock layers for map" option.

  • Thanks for the detailed response (and sorry for the delay in accepting the answer). I hadn't considered using sql to generate the coverage layer, which in retrospect was very narrow thinking. – tomtomnz Sep 3 '16 at 19:30
2

You need a loop in a loop, this is not an out of the box possibility in the QGIS Print Composer without a Python script, or some manually repetition in the Print Composer.

The manually way could be using 30 pages in one composer. This is set on the composition tab. If you use a alignment line (the red one), you could place the maps aligned. For each map you have to 'Lock layers for map item' for the one contour you want for the map. This will give you 30 maps in one PDF. You will just have to setup the Atlas coverage loop for one of the maps.

This may be too much manually work for one go, but if you need to print this setup several times, it may be worth a go.

map

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.