I am looking for automating printing maps with the same extent but different data and theme. I have a map document with 10 layers and need to print 5 maps (2 layer in each map). I made a layer list (lists) and looking for printing maps with layer's symbology, title and layout. I have attached herewith my script. Thanks in advance.
You can use arcpy.mapping to add and remove layers from a MapDocument using the following code:
<SPAN class="keyword token">import</SPAN> arcpy mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"C:\Project\Project.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> df <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListDataFrames<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"New Data Frame"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> layer <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>Layer<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"C:\Project\Data\Orthophoto.lyr"</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>AddLayer<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">,</SPAN> layer<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"BOTTOM"</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>RemoveLayer<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">,</SPAN> layer<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
So you can create an MXD that is a template (set extent, layout etc), add the relevant layers to it, then use arcpy.mapping.PrintMap() PrintMap—Help | ArcGIS Desktop, remove the layers, add the next set and so on.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.