ArcGIS批量导出图层脚本

该脚本会将ArcMap中的每一个图层单独导出为图片

import arcpy
import os


def exportbatch(outdir, export_width, export_height, resolution):
    # outdir the directory to store the exported pngs
    mxd = arcpy.mapping.MapDocument('CURRENT')
    df = arcpy.mapping.ListDataFrames(mxd)[0]
    layers = arcpy.mapping.ListLayers(mxd, data_frame=df)
    for layer in layers:
        for lay in layers:
            lay.visible = False
        layer.visible = True
        filename = layer.name
        if filename.endswith('tif'):
            filename = filename[0:-4]
        filename += '.tif'
        outpath = os.path.join(outdir, filename)
        arcpy.mapping.ExportToTIFF(map_document=mxd, out_tiff=outpath, data_frame=df, df_export_width=export_width,
                                   df_export_height=export_height, resolution=resolution, tiff_compression='LZW')

    arcpy.AddMessage('Export gas beed finised!')


outdir = arcpy.GetParameterAsText(0)
export_width = arcpy.GetParameter(1)
export_height = arcpy.GetParameter(2)
resolution = arcpy.GetParameter(3)
exportbatch(outdir, export_width, export_height, resolution)

脚本添加方式参考ArcGIS批量渲染图层脚本

脚本参数设置如下:
ArcGIS批量导出图层脚本_第1张图片

  • 工具运行界面
    ArcGIS批量导出图层脚本_第2张图片

你可能感兴趣的:(Arcpy与ArcGIS,arcgis,gis,python,图像处理)