How to export a mxd to a image with transparent background

المشرف العام

Administrator
طاقم الإدارة
I cannot get ArcMap 10.0 or 10.1 to "Export Map" to a png or gif with a transparent background -- no matter what I set the background and transparent colors to. Thus, I created the following script, which does the trick, but I'd rather be able to get the default tool in ArcMap to do it. Any better ideas?

# Purpose: This script exports an MXD view to a png file with transparent background,# which is problematic to do manually due to a Windows-related bug in the ArcMap UI.# Warning: It will make any white features (e.g. the default background color) transparent.## INSTRUCTIONS:# When in ArcMap, viewing a saved mxd...# 1. From the Geoprocessing menu, select 'Python'.# 2. In the new Python window, right-click somewhere after >>>, and select 'Load...'# 3. Select this script.# 4. When this script appears, press Enter twice to run it.# 5. A new [mxd-name].png with transparent background will appear in the same directory as the mxd.# 6. When finished/satisfied, close the Python window.# http://forums.arcgis.com/threads/65463-Zoom-to-tile-and-Export-to-JPEG-with-World-Fileimport arcpypng_resolution = 300 # Can adjust DPI# Set mxd and png namemxd = arcpy.mapping.MapDocument("CURRENT")pngname = mxd.filePath.replace(".mxd",".png")df = arcpy.mapping.ListDataFrames(mxd)[0]# Calculate ideal image size from the mxd view and desired DPIpng_width = int((df.extent.XMax - df.extent.XMin) * png_res * 12 / df.scale)png_height = int((df.extent.YMax - df.extent.YMin) * png_res * 12 / df.scale)#Export PNGprint "Exporting: {0}\n{1} x {2} pixels, {3}-dpi".format(pngname,png_width,png_height,png_res)arcpy.mapping.ExportToPNG(mxd, pngname, df, df_export_width = png_width, df_export_height = png_height, resolution = png_res, transparent_color = "255, 255, 255")#Clean updel df, pngname, png_res, png_width, png_height, mxd

أكثر...
 
أعلى