当前位置:   article > 正文

arcgispython脚本开发工具_ArcGIS中ArcTooxbox 的新增工具tbx与大家分享即19个python脚本程序...

arcgis tbx工具开发与修改

感谢原作者分享出这么好的资料,这些工具是Arctoolbox里面没有的。可能工具本身不常用,但每个工具都提供了源代码,对于学习python脚本的同学,是非常好的资料,不敢独享,分享给华夏坛友!

需要说明的是:

1、这些工具需要ArcGIS10.0以上环境,9.3以下都是无法运行的,可以再Arcgis10中导出9.3版进行使用;

2、仅供大家参考学习使用,请勿用于其他用途,版权归原作者所有!

下载完毕后,大家可以看到有相关的文件夹,里面包括相关的

ArcTooxbox 的工具tbx

测试数据

每个工具的Python脚本

相关的操作说明感兴趣的大家可以下载适用一下,这个对经常使用python和ArcGIS结合开发的朋友很有帮助,因为它提供了关于每一个GP功能的Python源代码,大家可以看看这些,将这些功能结合自己的项目,进行结合,效果应该不错。

# Author: ESRI

# Date: July 5, 2010

# Version: ArcGIS 10.0

# Purpose: This script will iterate through each MXD in a folder and report information about each

# map document, it's data frames and layers. The script is intended to run from a script

# tool that requires two input parameters:

# 1) folder containing MXDs,

# 2) an output text file.

#

# The resulting text file will automatically open.

import arcpy, datetime, os

try:

arcpy.gp.overwriteOutput = True

#Read input parameters from GP dialog

folderPath = arcpy.GetParameterAsText(0)

output = arcpy.GetParameterAsText(1)

#Create an output file

outFile = open(output, "w")

#Report header

outFile.write("MXD REPORT: \n")

outFile.write("\n")

outFile.write("This report is for all MXDs in a folder. It lists relevant information about\n")

outFile.write("map document properties, data frame, layer, and table information for each MXD\n")

outFile.write("in a system folder\n")

outFile.write("\n")

outFile.write("Date: " + str(datetime.datetime.today().strftime("%B %d, %Y")) + "\n")

#Loop through each MXD file

count = 0

for filename in os.listdir(folderPath):

fullpath = os.path.join(folderPath, filename)

if os.path.isfile(fullpath):

if filename.lower().endswith(".mxd"):

#Reference MXD

mxd = arcpy.mapping.MapDocument(fullpath)

count = 1

#Format output value

if mxd.author =="": authorValue = "None"

else: authorValue = mxd.author

if mxd.summary =="": summaryValue = "None"

else: summaryValue = mxd.summary

BDS = arcpy.mapping.ListBrokenDataSources(mxd)

if len(BDS) == 0: BDSValue = "None"

else: BDSValue = "A total of " + str(len(BDS)) + " broken data source(s)."

#Write MXD data to file

outFile.write("\n")

outFile.write("\n")

outFile.write("------------------------------------------------------------------- \n")

outFile.write("MAPDOCUMENT: " + os.path.basename(mxd.filePath) + "\n")

outFile.write("------------------------------------------------------------------- \n")

outFile.write("\n")

outFile.write("\t Path: " + mxd.filePath + "\n")

outFile.write("\t Last Saved: " + str(mxd.dateSaved) + "\n")

outFile.write("\t Author: " + authorValue + "\n")

outFile.write("\t Summary: " + summaryValue + "\n")

outFile.write("\t Relative Paths: " + str(mxd.relativePaths) + "\n")

outFile.write("\t Broken Data Sources: " + BDSValue + "\n")

#Reference each data frame and report data

DFList = arcpy.mapping.ListDataFrames(mxd)

for df in DFList:

#Format output values

if df.description == "": descValue = "None"

else: descValue = df.description

#Write data frame data to file

outFile.write("\n")

outFile.write("\n")

outFile.write("\t DATA FRAME: " + df.name + "\n")

outFile.write("\n")

outFile.write("\t\t Description: " + descValue + "\n")

outFile.write("\t\t Spatial Reference: " + df.spatialReference.name + "\n")

outFile.write("\t\t Transformation(s): " + str(df.geographicTransformations) + "\n")

outFile.write("\t\t Map Units: " + df.mapUnits + "\n")

try:

outFile.write("\t\t Scale: " + str(df.scale) + "\n")

except:

outFile.write("\t\t Scale: Unknown \n")

outFile.write("\t\t Rotation: " + str(df.rotation) + "\n")

#Reference each layer in a data frame

lyrList = arcpy.mapping.ListLayers(mxd, "", df)

for lyr in lyrList:

outFile.write("\n")

outFile.write("\t\t LAYER: " + lyr.name + "\n")

outFile.write("\t\t\t Group Layer Path: " + lyr.longName + "\n")

if lyr.supports("dataSource"):

outFile.write("\t\t\t Data Source: " + lyr.dataSource + "\n")

try:

outFile.write("\t\t\t Dataset type: " + arcpy.Describe(lyr.dataSource).datasettype + "\n")

except:

outFile.write("\t\t\t Dataset type: Unknown (could be a broken data source) \n")

else: outFile.write("\t\t\t Data Source: N/A \n")

if lyr.supports("definitionQuery"):

if lyr.definitionQuery == "":

outFile.write("\t\t\t Query Definition: None \n" )

else: outFile.write("\t\t\t Query Definition: " + lyr.definitionQuery + "\n")

else: outFile.write("\t\t\t Query Definition: N/A \n")

#Reference each table in a data frame

tableList = arcpy.mapping.ListTableViews(mxd, df, "")

for table in tableList:

outFile.write("\n")

outFile.write("\n")

outFile.write("\t\t TABLEVIEW: " + table.name + "\n")

outFile.write("\n")

outFile.write("\t\t\t Data Source: " + table.dataSource + "\n")

if table.definitionQuery == "":

outFile.write("\t\t\t Query Definition: None \n")

else: outFile.write("\t\t\t Query Definition: " + table.definitionQuery + "\n")

del mxd

if count ==0:

outFile.write("\n")

outFile.write("\n")

outFile.write("---------------------------------------------------------------------------------- \n")

outFile.write(" NO MXD FILES FOUND \n")

outFile.write("---------------------------------------------------------------------------------- \n")

outFile.close()

#Open resulting text file

os.startfile(output)

#Delete variables that reference data on disk

del folderPath, output, outFile, fullpath

except Exception, e:

import traceback

map(arcpy.AddError, traceback.format_exc().split("\n"))

arcpy.AddError(str(e))

原文出自CSDN论坛:http://blog.csdn.net/linghe301/article/details/7912007

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/310642
推荐阅读
相关标签
  

闽ICP备14008679号