﻿{"id":2772,"date":"2015-11-25T11:58:21","date_gmt":"2015-11-25T10:58:21","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=2772"},"modified":"2023-05-24T08:00:03","modified_gmt":"2023-05-24T06:00:03","slug":"pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/","title":{"rendered":"Pour d\u00e9buter avec Python ArcGis : Exporter un mxd en format pdf"},"content":{"rendered":"<p>D\u00e9buter avec Python sur ArcGIS est plus facile qu\u2019il n\u2019y para\u00eet. Il n\u2019est pas n\u00e9cessaire de ma\u00eetriser Python pour l\u2019utiliser de mani\u00e8re basique dans notre travail avec ArcGIS et ESRI met \u00e0 votre disposition une aide compl\u00e8te et pleine d&rsquo;exemples de code. La lecture d&rsquo;un article de Mapping Gis ) a largement inspir\u00e9 ce qui suit.<br \/>\nNous allons donc voir comment g\u00e9n\u00e9rer un fichier pdf de la carte d&rsquo;un projet ArcGis (.mxd), sans ouvrir le projet. Supposons que ce document doit \u00eatre tenu \u00e0 jour apr\u00e8s des mises \u00e0 jour des donn\u00e9es tr\u00e8s fr\u00e9quentes.<br \/>\n<!--more--><\/p>\n<p>Nous vous invitons \u00e0 consulter l&rsquo;article <a href=\"http:\/\/www.sigterritoires.fr\/index.php\/arcgis-et-python-avant-de-faire-vos-premiers-pas\/\">ArcGis et Python:avant de faire les premiers pas<\/a> pour voir plus en d\u00e9tail les diff\u00e9rentes options pour ex\u00e9cuter nos processus avec un code Python.<br \/>\nNous allons voir ici trois des options: par la fen\u00eatre de commande, avec la console Python d&rsquo;ArcGis et avec la console Python d&rsquo;un autre IDE.<br \/>\nMais proc\u00e9dons dans l&rsquo;ordre. D&rsquo;abord nous devons trouver le code Python qui nous int\u00e9resse.<\/p>\n<h2>Recherche de code Python dans l&rsquo;aide ArcGis<\/h2>\n<p>Avec votre navigateur allez \u00e0 l&rsquo;adresse <a href=\"http:\/\/desktop.arcgis.com\/fr\/\">http:\/\/desktop.arcgis.com\/fr\/<\/a> .<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2775\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py1-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png?fit=1293%2C294&amp;ssl=1\" data-orig-size=\"1293,294\" 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=\"py1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png?fit=640%2C146&amp;ssl=1\" class=\"aligncenter wp-image-2775 size-large\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1-1024x233.png?resize=640%2C146\" alt=\"http:\/\/desktop.arcgis.com\/fr\/\" width=\"640\" height=\"146\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png?resize=1024%2C233&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png?resize=300%2C68&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py1.png?w=1293&amp;ssl=1 1293w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a>Dans le champ de recherche tapez les mots cl\u00e9s recherch\u00e9s : <em><strong>mxd to pdf arcpy<\/strong><\/em><\/p>\n<p>Dans le r\u00e9sultat de la recherche vous trouverez <strong>ExportToPDF\u2014Help | ArcGIS for Desktop<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2776\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py2-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png?fit=1035%2C801&amp;ssl=1\" data-orig-size=\"1035,801\" 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=\"py2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png?fit=640%2C495&amp;ssl=1\" class=\"aligncenter wp-image-2776 size-large\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2-1024x792.png?resize=640%2C495\" alt=\"r\u00e9sultat de la recherche arcpy\" width=\"640\" height=\"495\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png?resize=1024%2C792&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png?resize=300%2C232&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py2.png?w=1035&amp;ssl=1 1035w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>En cliquant sur ce lien vous aurez la page d&rsquo;aide pour le code qui nous int\u00e9resse : <a href=\"http:\/\/desktop.arcgis.com\/fr\/desktop\/latest\/analyze\/arcpy-mapping\/exporttopdf.htm\">http:\/\/desktop.arcgis.com\/fr\/desktop\/latest\/analyze\/arcpy-mapping\/exporttopdf.htm<\/a><\/p>\n<p>Vous trouvez, en particulier, deux paragraphes fondamentaux:<\/p>\n<p>La syntaxe Python de la commande<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2777\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py3-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png?fit=844%2C398&amp;ssl=1\" data-orig-size=\"844,398\" 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=\"py3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png?fit=640%2C302&amp;ssl=1\" class=\"aligncenter wp-image-2777 size-full\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png?resize=640%2C302\" alt=\"syntaxe de la commande python\" width=\"640\" height=\"302\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png?w=844&amp;ssl=1 844w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py3.png?resize=300%2C141&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a>Et des exemples de code<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2778\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py4-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png?fit=836%2C515&amp;ssl=1\" data-orig-size=\"836,515\" 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=\"py4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png?fit=640%2C394&amp;ssl=1\" class=\"aligncenter wp-image-2778 size-full\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png?resize=640%2C394\" alt=\"exemples de code de la commande\" width=\"640\" height=\"394\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png?w=836&amp;ssl=1 836w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py4.png?resize=300%2C185&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a>Pour cet exemple vous pouvez tout de suite voir que tout ce qu&rsquo;il faut pour ex\u00e9cuter la commande c&rsquo;est le nom du mxd et le nom du fichier pdf \u00e0 produire.<\/p>\n<h2>Ex\u00e9cution \u00e0 partir de la ligne de commande<\/h2>\n<p>Prenons comme exemple une carte simple avec les campings ouverts au public \u00e0 la date d\u2019aujourd\u2019hui. La couche campings est tenue \u00e0 jour par un autre\u00a0 traitement. Ce que nous souhaitons c&rsquo;est de produire le pdf du jour courant. Voici la fen\u00eatre de mise en page du document mxd :<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2780\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py5-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5.png?fit=553%2C757&amp;ssl=1\" data-orig-size=\"553,757\" 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=\"py5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5.png?fit=553%2C757&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2780\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5-219x300.png?resize=219%2C300\" alt=\"fen\u00eatre de mise en page du document mxd\" width=\"219\" height=\"300\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5.png?resize=219%2C300&amp;ssl=1 219w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py5.png?w=553&amp;ssl=1 553w\" sizes=\"auto, (max-width: 219px) 100vw, 219px\" \/><\/a>Pour ex\u00e9cuter la commande, on ouvre une fen\u00eatre invite de commande :<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2781\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py6-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6.png?fit=678%2C340&amp;ssl=1\" data-orig-size=\"678,340\" 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=\"py6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6.png?fit=640%2C321&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2781\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6-300x150.png?resize=300%2C150\" alt=\"fen\u00eatre invite des commandes\" width=\"300\" height=\"150\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6.png?resize=300%2C150&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py6.png?w=678&amp;ssl=1 678w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Vous lancez Python en tapant simplement<\/p>\n<p><em><strong>python<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2782\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py7-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7.png?fit=677%2C345&amp;ssl=1\" data-orig-size=\"677,345\" 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=\"py7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7.png?fit=640%2C326&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2782\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7-300x153.png?resize=300%2C153\" alt=\"lancement de python dans l 'invite de commandes\" width=\"300\" height=\"153\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7.png?resize=300%2C153&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py7.png?w=677&amp;ssl=1 677w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>les trois chevrons (&gt;&gt;&gt;) indiquent que vous pouvez entrer votre commande Python.<\/p>\n<p>La premi\u00e8re commande sert \u00e0 charger dans Python les fonctions d\u2019ArcGis. Tapez<\/p>\n<p><em><strong>import arcpy<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2783\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py8-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8.png?fit=668%2C341&amp;ssl=1\" data-orig-size=\"668,341\" 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=\"py8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8.png?fit=640%2C327&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2783\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8-300x153.png?resize=300%2C153\" alt=\"import arcpy\" width=\"300\" height=\"153\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8.png?resize=300%2C153&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py8.png?w=668&amp;ssl=1 668w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>C\u2019est tout ce qu\u2019il faut pour pouvoir ex\u00e9cuter notre commande qui va g\u00e9n\u00e9rer notre fichier pdf \u00e0 partir du mxd. On rentre alors la commande :<\/p>\n<p><em><strong>mxd=arcpy.mapping.MapDocument(r\u00a0\u00bbC:\\Quimper\\geocodage.mxd\u00a0\u00bb)<\/strong><\/em><br \/>\n<em><strong> arcpy.mapping.ExportToPDF(mxd,r\u00a0\u00bbC:\\Quimper\\Campings.pdf\u00a0\u00bb)<\/strong><\/em><br \/>\n<em><strong> del mxd<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2784\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py9-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9.png?fit=678%2C341&amp;ssl=1\" data-orig-size=\"678,341\" 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=\"py9\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9.png?fit=640%2C322&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2784\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9-300x151.png?resize=300%2C151\" alt=\"cr\u00e9ation du pdf avec python\" width=\"300\" height=\"151\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9.png?resize=300%2C151&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py9.png?w=678&amp;ssl=1 678w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(vous pouvez copier-coller directement les trois lignes ensemble vers la fen\u00eatre d&rsquo;invite de commandes)<\/p>\n<p>et on obtient imm\u00e9diatement le fichier pdf<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2785\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png?fit=1127%2C732&amp;ssl=1\" data-orig-size=\"1127,732\" 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=\"py10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png?fit=640%2C416&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2785\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10-300x195.png?resize=300%2C195\" alt=\"fichier pdf r\u00e9sultat de loa commande python\" width=\"300\" height=\"195\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png?resize=300%2C195&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png?resize=1024%2C665&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py10.png?w=1127&amp;ssl=1 1127w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>A noter que la date \u00e9tant du texte dynamique d&rsquo;ArcMap est bien renseign\u00e9e avec la date du jour.<\/p>\n<p>Si vous stockez les lignes de commande dans un fichier texte, avec une extension .py, vous pouvez ex\u00e9cuter la totalit\u00e9 de la commande en une seule ligne de commande:<\/p>\n<p>Ouvrez la fen\u00eatre d&rsquo;invite de commande, puis tapez directement<\/p>\n<p><em><strong>python.exe campings.py<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2786\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py11-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11.png?fit=669%2C344&amp;ssl=1\" data-orig-size=\"669,344\" 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=\"py11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11.png?fit=640%2C329&amp;ssl=1\" class=\"aligncenter size-medium wp-image-2786\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11-300x154.png?resize=300%2C154\" alt=\"ex\u00e9cution du fihier .py\" width=\"300\" height=\"154\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11.png?resize=300%2C154&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py11.png?w=669&amp;ssl=1 669w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Vous obtenez le m\u00eame r\u00e9sultat en pdf.<\/p>\n<h2>Ex\u00e9cution \u00e0 partir de la console Python d&rsquo;ArcGis<\/h2>\n<p>L&rsquo;avantage d&rsquo;ex\u00e9cuter le code Python \u00e0 partir de la console Python d&rsquo;ArcMap r\u00e9side surtout dans le fait de b\u00e9n\u00e9ficier de l&rsquo;aide syntaxique.<\/p>\n<p>Comme vous pouvez le voir en consultant la syntaxe de notre commande, il y a toute une s\u00e9rie de param\u00e8tres optionnels. Par exemple, la d\u00e9finition du fichier pdf en sortie. Par d\u00e9faut, elle est de 300dpi. Si vous souhaitez qu&rsquo;elle soit de 600 dpi vous devez ajouter l&rsquo;option dans la ligne de commande<\/p>\n<p><em><strong>arcpy.mapping.ExportToPDF(mxd,r\u00a0\u00bbC:\\Quimper\\Campings.pdf\u00a0\u00bb,resolution=600)<\/strong><\/em><\/p>\n<p>Dans ce cas, il est plus facile d&rsquo;utiliser la console Python:<\/p>\n<p>On ouvre la console Python en cliquant,dans la fen\u00eatre ArcMap,\u00a0 sur le bouton correspondant<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1802\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/arcgis-et-python-avant-de-faire-vos-premiers-pas\/py6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png?fit=1014%2C355&amp;ssl=1\" data-orig-size=\"1014,355\" 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=\"py6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png?fit=630%2C221&amp;ssl=1\" class=\"aligncenter wp-image-1802 size-large\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6-630x221.png?resize=630%2C221\" alt=\"ouverture de la console python d'arcmap\" width=\"630\" height=\"221\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png?resize=630%2C221&amp;ssl=1 630w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png?resize=300%2C105&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/06\/py6.png?w=1014&amp;ssl=1 1014w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/a><\/p>\n<p>Vous n&rsquo;avez pas \u00e0 rentrer la ligne import arcpy dans la console ArcMap.<\/p>\n<p>D\u00e8s que vous tapez la commande <em><strong>arcpy.mapping.ExportToPDF<\/strong><\/em>, vous verrez appara\u00eetre la syntaxe de celle-ci dans la fen\u00eatre de droite:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2787\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py12-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png?fit=953%2C226&amp;ssl=1\" data-orig-size=\"953,226\" 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=\"py12\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png?fit=640%2C152&amp;ssl=1\" class=\"aligncenter wp-image-2787 size-full\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png?resize=640%2C152\" alt=\"aide syntaxique de la console python d'arcgis\" width=\"640\" height=\"152\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png?w=953&amp;ssl=1 953w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py12.png?resize=300%2C71&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Une fois ex\u00e9cut\u00e9e, la commande produit le m\u00eame fichier pdf que pr\u00e9c\u00e9demment.<\/p>\n<h2>A partir de la console d\u2019un autre IDE<\/h2>\n<p>Les diff\u00e9rents environnements int\u00e9gr\u00e9s de d\u00e9veloppement sont, en principe, destin\u00e9s \u00e0 faire des ex\u00e9cutables. Mais, bien s\u00fbr, ils poss\u00e8dent des consoles d\u2019interpr\u00e9tation \u00e9quivalentes \u00e0 la console Python d\u2019ArcMap.<\/p>\n<p>Par exemple,<a href=\"https:\/\/code.google.com\/p\/pyscripter\/\"> PyScripter<\/a>, vous permet de rentrer et ex\u00e9cuter les deux lignes de commande. La diff\u00e9rence se situe sur l\u2019aide \u00e0 l\u2019\u00e9criture des commandes:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2789\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/pour-debuter-avec-python-arcgis-exporter-un-mxd-en-format-pdf\/py13-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png?fit=1215%2C674&amp;ssl=1\" data-orig-size=\"1215,674\" 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=\"py13\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png?fit=640%2C355&amp;ssl=1\" class=\"aligncenter wp-image-2789 size-large\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13-1024x568.png?resize=640%2C355\" alt=\"py13\" width=\"640\" height=\"355\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png?resize=1024%2C568&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png?resize=300%2C166&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2015\/11\/py13.png?w=1215&amp;ssl=1 1215w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a>En g\u00e9n\u00e9ral vous aurez plus de fonctionnalit\u00e9s offertes par un IDE que par la console Python d\u2019ArcMap. Mais si vous restez \u00e0 l\u2019utilisation de la ligne de commande les deux sont assez \u00e9quivalents. La diff\u00e9rence essentielle est que l\u2019IDE vous permet d\u2019\u00e9crire, tester et debugger des scripts Python complets.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>D\u00e9buter avec Python sur ArcGIS est plus facile qu\u2019il n\u2019y para\u00eet. Il n\u2019est pas n\u00e9cessaire de ma\u00eetriser Python pour l\u2019utiliser de mani\u00e8re basique dans notre travail avec ArcGIS et ESRI met \u00e0 votre disposition une aide&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":[145,146,222],"tags":[15,65,300,153,131,223],"class_list":["post-2772","post","type-post","status-publish","format-standard","hentry","category-arcgis","category-arcmap","category-python","tag-arcgis","tag-arcmap","tag-mxd","tag-pdf","tag-python","tag-script"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-II","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/2772","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=2772"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/2772\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=2772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=2772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=2772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}