使用arcpy.mapping批量作图,如何让工具脚本窗口显示parameter
使用arcpy.mapping批量作图,然后把python脚本导入到工具脚本中,如何改写程序让parameter中显示要输入哪个mxd文档以及输出文件路径?
以下是我的程序:
# Export Map in Batch
#coding=gbk
import arcpy
mxd = arcpy.mapping.MapDocument(r"D:\ArcGIS\2015\Map2015.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
inLayer=arcpy.mapping.ListLayers(mxd, "", df)
for layer in inLayer:
#匹配图层名称
layerNameStr = layer.name
picName=layerNameStr
picName=picName+".tif"
titleName =layerNameStr
#设置标题
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.name == "Month":
elm.text = str(titleName[-11:-8])
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.name == "Depth":
elm.text = str(titleName[-7:-5])
#显示图层
layer.visible=True
#输出底图
folderpath = "D:\\ArcGIS\\2015\\2015_TRY\\"
folderpath=folderpath.decode('gbk')
fullpath = folderpath+picName
arcpy.mapping.ExportToTIFF(mxd, fullpath,resolution=300)
#关闭图层
layer.visible=False
以下是我的程序:
# Export Map in Batch
#coding=gbk
import arcpy
mxd = arcpy.mapping.MapDocument(r"D:\ArcGIS\2015\Map2015.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
inLayer=arcpy.mapping.ListLayers(mxd, "", df)
for layer in inLayer:
#匹配图层名称
layerNameStr = layer.name
picName=layerNameStr
picName=picName+".tif"
titleName =layerNameStr
#设置标题
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.name == "Month":
elm.text = str(titleName[-11:-8])
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.name == "Depth":
elm.text = str(titleName[-7:-5])
#显示图层
layer.visible=True
#输出底图
folderpath = "D:\\ArcGIS\\2015\\2015_TRY\\"
folderpath=folderpath.decode('gbk')
fullpath = folderpath+picName
arcpy.mapping.ExportToTIFF(mxd, fullpath,resolution=300)
#关闭图层
layer.visible=False
2 个回复
菠萝仔
赞同来自: 张佳期
arcpy.GetParameterAsText()函数;
具体可以参考:https://zhuanlan.zhihu.com/p/28860745
张佳期
赞同来自:
要回复问题请先登录或注册
发起人
相关问题
问题状态