【ArcPy】从地图文档MXD出图(PDF或JPG格式)

Python工具代码,非Python窗口脚本,可以自行编辑处理一下。

复制代码
# coding=gbk
import arcpy
from arcpy import mapping
import os

def main():
    inFolder=arcpy.GetParameterAsText(0)
    outFormat=arcpy.GetParameterAsText(1).lower()
    resolution=arcpy.GetParameter(2)
    outFolder=arcpy.GetParameterAsText(3)    
    for r,dirs,files in os.walk(inFolder):
        for mxdFile in files:
            if mxdFile[-3:].lower()=="mxd":
                arcpy.SetProgressorLabel(u"Exporting {}".format(mxdFile))
                arcpy.AddMessage('>>>正在输出 {} 文档为图件。'.format(mxdFile))
                mxd=mapping.MapDocument(os.path.join(r,mxdFile))
                if outFormat=='jpg':
                    mapping.ExportToJPEG(mxd,os.path.join(outFolder,mxdFile[:-3]+"jpg"),resolution=resolution)
                elif outFormat=='pdf':
                    mapping.ExportToPDF(mxd,os.path.join(outFolder,mxdFile[:-3]+"pdf"))
                del mxd

if __name__ == '__main__':
    main()
复制代码

 

posted @   yzhyingcool  阅读(177)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示