I have 2 layers in QGIS map, One is raster layer and other is a vector layer having location of sites. Both are having same CRS. I want to zoom in to each feature in the vector layer and save the map. I am using QGIS 3.8 I also tried the QTimer function as well as indicated on How to loop through features in a layer, zoom to that feature and export to png but it doesn't seem to be working.

Here is the code

    ids =None
    def get_screenshots(layer):
        global id
        ids = layer.allFeatureIds()
        def savemap():
        for id in ids:

    l = iface.activeLayer()
  • 3
    Please be more specific than "it doesn't seem to be working". Is there an error message? – Erik Oct 10 '19 at 13:13
  • @Erik the loop runs through and a single image is saved multiple times in the folder. Also, I am not able to see changes in the in regard to the ZoomToSelected function – Sumit Singh Oct 10 '19 at 13:28
  • 1
    Please use the edit button beneath your question to revise it with any requested information. – PolyGeo Oct 11 '19 at 3:56

I would suggest using the Atlas feature of QGIS, which does exactly what you need.

Automating the creation of maps is the job of the Atlas feature, a real ace of QGIS when it comes to production.

It is very easy to master and ensures powerful results.

From any layout, access the Atlas feature by clicking on the Altas menu item:

enter image description here

There are also many tutorials around. Here are just two I liked:



Disclosure: this is a duplicate answer of mine from How do I create automated maps for attributes in QGIS 3.8.2? ;)

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.