<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Ballontekst Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.BallontekstChar
{mso-style-name:"Ballontekst Char";
mso-style-priority:99;
mso-style-link:Ballontekst;
font-family:"Tahoma","sans-serif";}
span.E-mailStijl21
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:215318161;
mso-list-type:hybrid;
mso-list-template-ids:456304384 -1818474900 68354051 68354053 68354049 68354051 68354053 68354049 68354051 68354053;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Jorris,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks and have found a slightly different solution – not 100% automatic but only thing I need to do is push a button everytime the map has loaded in full. I ran through and created 250 maps as JPG in ca. 15 minutes this way…. This might be a solution for anybody who need to:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='font-size:11.0pt;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Iterate through a number of different values for features (in this case ‘clusters’ and ‘number on inhabitants’ and get the right focus and styles for each layer.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='font-size:11.0pt;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Either toggle on and off different layers<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>For those interested – here’s the python code.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Frank<o:p></o:p></span></p><div style='mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal style='border:none;padding:0cm'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>import sys<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>sys.path.insert(0,'C:/Python27')<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>sys.path.insert(0,'C:/Python27/Lib/site-packages')<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>from qgis.core import *<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>from qgis.gui import *<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>from qgis.utils import *<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>from PyQt4.QtCore import *<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>from PyQt4.QtGui import *<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>import os, time<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'># File location & specifications <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>PROJECTPATH = 'C:/Users/Frank/ Targetting/maps/'<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>EXTSNAPSHOTS = '.jpg'<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>EXTSNAPSHOTS2 = '.png'<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>SUFFIX = 'Sterfte_v1'<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'># Clusterlijst<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>clusters = {1: 'Apeldoorn',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 2: 'Arnhem',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 3: 'Breda',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 4: 'Bussum',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 5: 'Den Haag',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 6: 'Deventer_Almelo',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 7: 'Eindhoven_Helmond',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 8: 'Emmen',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 9: 'Gouda',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 10: 'Groningen',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 11: 'Kerkrade',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 12: 'Leiden',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 13: 'Rotterdam',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 14: 'Tilburg',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 15: 'Utrecht_Zeist_Woerden',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 16: 'Venlo',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 17: 'Wageningen',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 18: 'Winterswijk_Doetinchem',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 19: 'Zeeland',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 20: 'Zutphen_Lochem_Vorden',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 21: 'Zwolle'<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'># real code <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>last_id = 1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>while last_id < 22:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'># set filters<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> canvas = qgis.utils.iface.mapCanvas()<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>acl = canvas.layer(0)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.mapCanvas().layer(0).selectAll()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> selection = '"Cluster" = ' + "\'" + str(clusters[last_id])+ "\'"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl.setSubsetString( selection )<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl = canvas.layer(1)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.mapCanvas().layer(1).selectAll()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> selection = '"Cluster" = ' + "\'" + str(clusters[last_id])+ "\'" + " AND " '"Inwoners" > 15000'<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl.setSubsetString( selection )<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl = canvas.layer(2)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> selection = '"Cluster" = ' + "\'" + str(clusters[last_id])+ "\'" + " AND " '"Inwoners" > 15000'<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl.setSubsetString( selection )<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl = canvas.layer(0)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.mapCanvas().refresh() <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.setActiveLayer(acl)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> # Zoom in and out to refresh potential issues with OpenLayer<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> canvas.zoomByFactor(3)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> canvas.zoomByFactor(0.5)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.zoomToActiveLayer()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> # specific code for cluster 10 as this is too large and only main part needs to be focussed<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> if last_id == 10 :<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> point = QgsPoint(698254,7.01707e+06)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> geom = QgsGeometry.fromPoint(point) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> center = geom.asPoint()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> rect = QgsRectangle(center, center) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> iface.mapCanvas().setExtent(rect) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> iface.mapCanvas().zoomScale(750000)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> acl = canvas.layer(0)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.mapCanvas().refresh()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> # Save project<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> p=QgsProject.instance()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> p.setFileName(PROJECTFILE)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> p.write()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> msgBox = QMessageBox()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> msgBox.setText("Map ready?")<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> msgBox.exec_()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> p = str(last_id) + 'mapCluster_' <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> qgis.utils.iface.mapCanvas().saveAsImage(PROJECTPATH+ p + SUFFIX + EXTSNAPSHOTS)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> last_id = last_id +1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Van:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Joris Hintjens [mailto:jorishin@gmail.com] <br><b>Verzonden:</b> 04 November 2014 20:43<br><b>Aan:</b> Frank van Baar<br><b>CC:</b> Qgis-user@lists.osgeo.org<br><b>Onderwerp:</b> Re: [Qgis-user] Python script to iterate through attributes and then refresh the canvas - doesn't show any map....<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>hello frank, for the OSM problem, see thread: <o:p></o:p></p><div><p class=MsoNormal> "Printing with OSM layer"<o:p></o:p></p></div><div><p class=MsoNormal>form earlier today and the answers of Joost and Paulo to that. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><div style='margin-left:3.0pt'><p class=MsoNormal><o:p> </o:p></p></div><div style='margin-left:3.0pt'><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal>Op 4-nov.-2014, om 13:59 heeft Frank van Baar <<a href="mailto:frank@van-baar.com">frank@van-baar.com</a>> het volgende geschreven:<o:p></o:p></p></div><p class=MsoNormal><br><br><o:p></o:p></p><div><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Joris,</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for your suggestion – didn’t realize atlas worked this way. It however does not completely do what I want to do – the layer which it changes the filter for also has specific formatting to highlight the region etc. AND the OSM layer doesn’t always display right.</span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Any other suggestions anyone?</span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><br>Frank</span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p></div><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><div><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Van:</span></b><span class=apple-converted-space><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> </span></span><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Joris Hintjens [<a href="mailto:jorishin@gmail.com">mailto:jorishin@gmail.com</a>]<span class=apple-converted-space> </span><br><b>Verzonden:</b><span class=apple-converted-space> </span>04 November 2014 11:27<br><b>Aan:</b><span class=apple-converted-space> </span>Frank van Baar<br><b>CC:</b><span class=apple-converted-space> </span><a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br><b>Onderwerp:</b><span class=apple-converted-space> </span>Re: [Qgis-user] Python script to iterate through attributes and then refresh the canvas - doesn't show any map....</span><o:p></o:p></p></div></div></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Why not use atlas generation in the print composer?<o:p></o:p></p></div><div><div><p class=MsoNormal> Seems to me this corresponds with your „what i’m trying to achieve”<o:p></o:p></p></div></div><div><div><p class=MsoNormal>grts<o:p></o:p></p></div></div><div><div><p class=MsoNormal>Joris<o:p></o:p></p></div></div><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><div><div><p class=MsoNormal> <o:p></o:p></p></div><div><div><div><p class=MsoNormal>Op 4-nov.-2014, om 09:14 heeft Frank van Baar <<a href="mailto:frank@van-baar.com"><span style='color:purple'>frank@van-baar.com</span></a>> het volgende geschreven:<o:p></o:p></p></div></div><div><p class=MsoNormal><br><br><br><o:p></o:p></p></div><div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Hi,</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Am</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>completely</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>stuck with a</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>QGIS</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>project in Python and tried everything but nothing seems to work.</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>The python script does work</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>as such</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>BUT the canvas never shows the map and therefor the exported maps are empty….</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>What I’m trying to achieve:</span><o:p></o:p></p><p><span lang=EN-US style='font-family:Symbol;color:#1F497D'>·</span><span lang=EN-US style='font-family:"Courier New";color:#1F497D'> </span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Create a Python script that iterates through a series of</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>ca. 2500</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>polygons</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>based on attribute value, zoom to layer extend and save the canvas for each attribute as an image file.</span><o:p></o:p></p><p><span lang=EN-US style='font-family:Symbol;color:#1F497D'>·</span><span lang=EN-US style='font-family:"Courier New";color:#1F497D'> </span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>I then use the image files in other</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>documents</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>The issue is that while manually I get the canvas to reload and display the map, this doesn’t happen when running the python script. Have tried couple of ways:</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>1. </span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Don’t load the project each time and just change the filter</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>2. </span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Add sleep timers to give the canvas time to refresh etc.</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>3. </span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Tried different QGIS versions (2.2, 2.4 & 2.6 on Win 64x)</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>But all to no avail….</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Hope somebody’s got a great idea how to solve it.</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Regards,</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Frank</span><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><i><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>Python code:</span></i><o:p></o:p></p><div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># File location & specifications</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>PROJECTPATH = 'C:/Users/Frank/Documents</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>/Targetting/Kaarten/'</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>PROJECTFILE = 'C:/Users/Frank/Documents</span><span lang=EN-US> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>/Targetting/TargettingkaartV26qgs.qgs'</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>EXTSNAPSHOTS = '.jpg'</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>EXTSNAPSHOTS2 = '.png'</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>SUFFIX = '65Plus_v1'</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>last_id = 1</span><o:p></o:p></p><p><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>while last_id < 5:</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># Clear map canvas</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>QgsMapLayerRegistry.instance().removeAllMapLayers()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.mapCanvas().refresh()</span><o:p></o:p></p><div><div><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p></div></div><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># Open QGIS project</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>QgsProject.instance().setFileName(PROJECTFILE)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>QgsProject.instance().read()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.mapCanvas().refresh()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>time.sleep(30) </span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>canvas = qgis.utils.iface.mapCanvas()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>acl = canvas.layer(0)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.mapCanvas().layer(0).selectAll()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>selection = 'RijNo = ' + str(last_id)</span><o:p></o:p></p><div><div><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p></div></div><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>acl.setSubsetString( selection )</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>acl.triggerRepaint</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>canvas.layer(1).triggerRepaint </span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>time.sleep(5) </span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.setActiveLayer(acl)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># Zoom in and out to refresh potential issues with OpenLayer</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>canvas.zoomByFactor(3)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>canvas.zoomByFactor(0.5)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.zoomToActiveLayer()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.mapCanvas().refresh()</span><o:p></o:p></p><div><div><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p></div></div><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>time.sleep(10)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># Save project</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>p=QgsProject.instance()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>p.setFileName(PROJECTFILE)</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>p.write()</span><o:p></o:p></p><p><span lang=EN-US> <span class=apple-converted-space> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'># Save content of map canvas as image</span><o:p></o:p></p><p><span lang=EN-US> </span><span style='font-family:"Calibri","sans-serif";color:#1F497D'>p = str(last_id) + 'kaart_'</span><o:p></o:p></p><p> <span class=apple-converted-space> </span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>qgis.utils.iface.mapCanvas().saveAsImage(PROJECTPATH+ p + SUFFIX + EXTSNAPSHOTS)</span><o:p></o:p></p><p><span lang=EN-US> </span><span style='font-family:"Calibri","sans-serif";color:#1F497D'>last_id = last_id +1</span><o:p></o:p></p></div><div><p class=MsoNormal><span lang=EN-US>_______________________________________________<br>Qgis-user mailing list<br></span><a href="mailto:Qgis-user@lists.osgeo.org"><span lang=EN-US style='color:purple'>Qgis-user@lists.osgeo.org</span></a><span lang=EN-US><br></span><a href="http://lists.osgeo.org/mailman/listinfo/qgis-user"><span lang=EN-US style='color:purple'>http://lists.osgeo.org/mailman/listinfo/qgis-user</span></a><o:p></o:p></p></div></div></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>