﻿{"id":3426,"date":"2016-08-24T07:27:29","date_gmt":"2016-08-24T06:27:29","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=3426"},"modified":"2023-07-14T10:29:31","modified_gmt":"2023-07-14T08:29:31","slug":"utiliser-script-runner-avec-qgis","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/","title":{"rendered":"Utiliser Script Runner avec QGis"},"content":{"rendered":"<p>Le plugin QGIS Python ScriptRunner fournit un outil interm\u00e9diaire pour les processus d&rsquo;automatisation de QGis, entre la console interactive Python et les d\u00e9veloppements compliqu\u00e9s de plugins. Il fournit une bo\u00eete de dialogue de gestion de scripts qui vous permet de charger facilement, cr\u00e9er, modifier et ex\u00e9cuter des scripts pour l&rsquo;automatisation de QGIS \u00e0 grande \u00e9chelle.<!--more--><\/p>\n<p>Tout d&rsquo;abord vous devez installer et activer le plugin \u00e0 partir du gestionnaire d&rsquo;extensions.<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3428\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?fit=1194%2C672&amp;ssl=1\" data-orig-size=\"1194,672\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?fit=640%2C360&amp;ssl=1\" class=\"aligncenter size-large wp-image-3428\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1-1024x576.png?resize=640%2C360\" alt=\"activation du plugin script runner de qgis\" width=\"640\" height=\"360\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr1.png?w=1194&amp;ssl=1 1194w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Vous trouverez alors le menu de lancement de <em><strong>Script Runner<\/strong><\/em> sous le menu <em><strong>Extensions<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3429\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png?fit=517%2C225&amp;ssl=1\" data-orig-size=\"517,225\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png?fit=517%2C225&amp;ssl=1\" class=\"aligncenter size-full wp-image-3429\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png?resize=517%2C225\" alt=\"menu de lancement du pugin script runner de qgis\" width=\"517\" height=\"225\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png?w=517&amp;ssl=1 517w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr2.png?resize=300%2C131&amp;ssl=1 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><\/p>\n<p>Avant de commencer \u00e0 l&rsquo;utiliser, vous devez configurer l&rsquo;\u00e9diteur de texte \u00e0 utiliser pour \u00e9diter vos scripts.<\/p>\n<ul>\n<li>Ouvrez <em><strong>Script Runner<\/strong><\/em>,<\/li>\n<li>cliquez sur l&rsquo;ic\u00f4ne de Pr\u00e9f\u00e9rences (la roue dent\u00e9e)<\/li>\n<li>Dans les Options g\u00e9n\u00e9rales cochez la case<em><strong> Edit Scripts Using&#8230;<\/strong><\/em><\/li>\n<li>Cliquez sur le bouton <em><strong>&#8230;<\/strong> <\/em>et pointez sur le programme d&rsquo;\u00e9dition de texte choisi<\/li>\n<\/ul>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3430\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png?fit=735%2C574&amp;ssl=1\" data-orig-size=\"735,574\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png?fit=640%2C500&amp;ssl=1\" class=\"aligncenter size-full wp-image-3430\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png?resize=640%2C500\" alt=\"configuration de l'\u00e9diteur de texte du plugin script runner de qgis\" width=\"640\" height=\"500\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png?w=735&amp;ssl=1 735w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr3.png?resize=300%2C234&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Vous pouvez utiliser le bloc-notes de Windows que vous trouverez dans C:\/Windows\/System32\/notepad.exe, mais vous pouvez aussi utiliser des outils plus performants tels que Notepad++ (gratuit et disponible sur le site<br \/>\nSi vous suivez l&rsquo;installation par d\u00e9faut vous devrez rentrer C:\/Program Files (x86)\/Notepad++\/notepad++.exe dans la fen\u00eatre de Script Runner.<\/p>\n<h2>Ce qu&rsquo;il faut savoir<\/h2>\n<p>Le point d&rsquo;entr\u00e9e de tout script dans <em><strong>Script Runner<\/strong><\/em> est la fonction:<\/p>\n<pre><span class=\"k\">def<\/span> <span class=\"nf\">run_script<\/span><span class=\"p\">(<\/span><span class=\"n\">iface<\/span><span class=\"p\">):<\/span><\/pre>\n<p><em><strong>run_script<\/strong><\/em> avec au moins un argument, l&rsquo;objet <em><strong>iface<\/strong><\/em>. Vous n&rsquo;avez aucune obligation d&rsquo;utiliser cet objet dans votre code, mais il doit obligatoirement \u00eatre pass\u00e9 comme premier ou unique argument.<\/p>\n<p>Quand vous cliquez sur l&rsquo;ic\u00f4ne <em><strong>New Script<\/strong><\/em>, de toutes fa\u00e7ons vous trouverez cette fonction d\u00e9j\u00e0 d\u00e9clar\u00e9e.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3431\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr4\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png?fit=714%2C578&amp;ssl=1\" data-orig-size=\"714,578\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png?fit=640%2C518&amp;ssl=1\" class=\"aligncenter size-full wp-image-3431\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png?resize=640%2C518\" alt=\"od\u00e8e de script cr\u00e9\u00e9 par l'outil nouveau script de script runner de qgis\" width=\"640\" height=\"518\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png?w=714&amp;ssl=1 714w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr4.png?resize=300%2C243&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Cette structure vous permet d&rsquo;utiliser directement, sans d\u00e9claration explicite, la classe <em>QGisInterface<\/em>. Mais sans autre d\u00e9claration, vous \u00eates limit\u00e9 aux m\u00e9thodes contenues dans cette classe.<\/p>\n<p>Par contre, vous pouvez ajouter des import de tous les modules souhait\u00e9s et les utiliser dans votre code. La cr\u00e9ation d&rsquo;un nouveau script avec <em><strong>Script Runner<\/strong><\/em> poss\u00e8de d\u00e9j\u00e0 quatre imports par d\u00e9faut:<\/p>\n<ul>\n<li>from PyQt4.QtCore import *<\/li>\n<li>from PyQt4.QtGui import *<\/li>\n<li>from qgis.core import *<\/li>\n<li>from qgis.gui import *<\/li>\n<\/ul>\n<p>que vous pouvez laisser ou enlever \u00e0 votre convenance, et aussi compl\u00e9ter avec tout autre module Python n\u00e9cessaire.<\/p>\n<h2>Comment \u00e7a marche?<\/h2>\n<p>Le fonctionnement de <em><strong>Script Runner<\/strong><\/em> est tr\u00e8s simple. Vous avez la barre d&rsquo;outils:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3432\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png?fit=469%2C96&amp;ssl=1\" data-orig-size=\"469,96\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png?fit=469%2C96&amp;ssl=1\" class=\"aligncenter size-full wp-image-3432\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png?resize=469%2C96\" alt=\"barre d'outils du plugin script runner de qgis\" width=\"469\" height=\"96\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png?w=469&amp;ssl=1 469w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr5.png?resize=300%2C61&amp;ssl=1 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/a><\/p>\n<p>Qui permet de cr\u00e9er un nouveau fichier .py, ajouter un fichier Python existant, ex\u00e9cuter le script s\u00e9lectionn\u00e9 dans la liste des fichiers scripts, recharger un fichier modifi\u00e9, etc.<\/p>\n<p>Et un menu contextuel (clic droit sur un script de la liste de gauche) qui vous permet principalement d&rsquo;ouvrir le fichier Python dans votre programme d&rsquo;\u00e9dition de texte et de le cr\u00e9er ou de le modifier .<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr6.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3433\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr6.png?fit=233%2C186&amp;ssl=1\" data-orig-size=\"233,186\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr6.png?fit=233%2C186&amp;ssl=1\" class=\"aligncenter size-full wp-image-3433\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr6.png?resize=233%2C186\" alt=\"menu contextuel de script runner de qgis\" width=\"233\" height=\"186\" \/><\/a><\/p>\n<p>Une fois sauvegard\u00e9 le contenu de l&rsquo;\u00e9diteur de texte, n&rsquo;oubliez pas de recharger le script pour que <em><strong>script runner<\/strong><\/em> prenne en compte les modifications que vous venez d&rsquo;apporter.<\/p>\n<p>Quand vous ex\u00e9cutez un script avec <em><strong>script runner<\/strong><\/em>, toutes les commandes <em><strong>print<\/strong> <\/em>sont dirig\u00e9es vers la console de sortie de <em><strong>script runner<\/strong><\/em>:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3434\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr7\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png?fit=717%2C583&amp;ssl=1\" data-orig-size=\"717,583\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png?fit=640%2C520&amp;ssl=1\" class=\"aligncenter size-full wp-image-3434\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png?resize=640%2C520\" alt=\"console de sortie du plugin script runner de qgis\" width=\"640\" height=\"520\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png?w=717&amp;ssl=1 717w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr7.png?resize=300%2C244&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a>Les messages d&rsquo;erreur sont aussi dirig\u00e9s vers cette fen\u00eatre.<\/p>\n<h2>Pour terminer, le param\u00e9trage de vos scripts<\/h2>\n<p>La derni\u00e8re chose \u00e0 savoir sur le fonctionnement de vos scripts dans <em><strong>script runner<\/strong><\/em> est comment passer des arguments \u00e0 votre script.<\/p>\n<p>La premi\u00e8re m\u00e9thode est de rentrer ces arguments dans la commande de lancement du script:<\/p>\n<pre><span class=\"k\">def<\/span> <span class=\"nf\">run_script<\/span><span class=\"p\">(<\/span><span class=\"n\">iface<\/span><span class=\"p\">,<\/span> <span class=\"n\">data_path<\/span><span class=\"p\">,<\/span> <span class=\"n\">buffer_size<\/span><span class=\"p\">):<\/span><\/pre>\n<p>Dans cet exemple, vous souhaitez deux arguments, un chemin de fichier et une valeur de tampon.<\/p>\n<p>Au moment de l&rsquo;ex\u00e9cution du script, une fen\u00eatre vous demandera de renseigner les param\u00e8tres:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3436\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr8\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?fit=936%2C580&amp;ssl=1\" data-orig-size=\"936,580\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?fit=640%2C397&amp;ssl=1\" class=\"aligncenter size-full wp-image-3436\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?resize=640%2C397\" alt=\"arguments d'un script dans le plugin script runner de qgis\" width=\"640\" height=\"397\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?w=936&amp;ssl=1 936w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?resize=300%2C186&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr8.png?resize=768%2C476&amp;ssl=1 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Une autre fa\u00e7on de passer des arguments est de cr\u00e9er une cha\u00eene de param\u00e9trage<\/p>\n<pre><span class=\"k\">def<\/span> <span class=\"nf\">run_script<\/span><span class=\"p\">(<\/span><span class=\"n\">iface<\/span><span class=\"p\">,<\/span> <span class=\"o\">**<\/span><span class=\"n\">myargs<\/span><span class=\"p\">):<\/span><\/pre>\n<p>Dans ce cas, vous devrez rentrer les diff\u00e9rents arguments sous forme de couples nom\/valeur<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3437\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/utiliser-script-runner-avec-qgis\/sr9\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png?fit=455%2C146&amp;ssl=1\" data-orig-size=\"455,146\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"sr9\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png?fit=455%2C146&amp;ssl=1\" class=\"aligncenter size-full wp-image-3437\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png?resize=455%2C146\" alt=\"cha\u00eene d'arguents pour un script du plugin script runner de qgis\" width=\"455\" height=\"146\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png?w=455&amp;ssl=1 455w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2016\/08\/sr9.png?resize=300%2C96&amp;ssl=1 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>Dans votre code vous acc\u00e9dez aux diff\u00e9rents arguments sous la forme:<\/p>\n<pre><span class=\"k\">def<\/span> <span class=\"nf\">run_script<\/span><span class=\"p\">(<\/span><span class=\"n\">iface<\/span><span class=\"p\">,<\/span> <span class=\"o\">**<\/span><span class=\"n\">myargs<\/span><span class=\"p\">):<\/span>\r\n    <span class=\"n\">data_path<\/span> <span class=\"o\">=<\/span> <span class=\"n\">myargs<\/span><span class=\"p\">[<\/span><span class=\"s\">'data_path'<\/span><span class=\"p\">]<\/span>\r\n    <span class=\"n\">my_buffer_size<\/span> <span class=\"o\">=<\/span> <span class=\"n\">myargs<\/span><span class=\"p\">[<\/span><span class=\"s\">'buffer_size'<\/span><span class=\"p\">]<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Le plugin QGIS Python ScriptRunner fournit un outil interm\u00e9diaire pour les processus d&rsquo;automatisation de QGis, entre la console interactive Python et les d\u00e9veloppements compliqu\u00e9s de plugins. Il fournit une bo\u00eete de dialogue de gestion de scripts&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"give_campaign_id":0,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,1,222,62],"tags":[131,58,223,338],"class_list":["post-3426","post","type-post","status-publish","format-standard","hentry","category-logiciel_libres","category-non-classe","category-python","category-qgis-2","tag-python","tag-qgis","tag-script","tag-script-runner"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-Tg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/3426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=3426"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/3426\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=3426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=3426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=3426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}