资源简介
arcgis脚本工具,按属性拆分图层。可编辑。arcgis脚本工具,按属性拆分图层。可编辑。arcgis脚本工具,按属性拆分图层。可编辑。
代码片段和文件信息
‘‘‘SplitlayerByAttributes.py
Author:
Dan Patterson
Dept of Geography and Environmental Studies
Carleton University Ottawa Canada
Dan_Patterson@carleton.ca
Date created June 23 2005
Modified Dec 29 2010
Purpose:
Converts each shape in a feature class to a separate shapefile
Properties (right-click on the tool and specify the following)
General
Name SplitlayerByAttributes
Label Split layer By Attributes
Desc Splits a layer according to attributes within the selected field producing
a separate shapefile for common attributes.
Source script SplitlayerByAttributes.py
Parameter list
Parameter Properties
Display Name Data type Type Direction MultiValue
argv[1] Input feature class Feature layer Required Input No
argv[2] Field to query Field Required Input No
argv[3] File basename String Optional Input No
argv[4] Output folder Folder Required Input No
‘‘‘
#--------------------------------------------------------------------
#Functions
import sys
reload(sys)
sys.setdefaultencoding(‘utf8‘)
def gp_create(vers=None):
‘‘‘create the geoprocessor for version 10‘‘‘
import arcpy
gp = arcpy
gp_version = vers
return [gp gp_version]
def gp_toolboxes(toolboxes gp gp_version):
‘‘‘a list of toolboxes to add to the geoprocessor gp‘‘‘
install_dir = gp.GetInstallInfo()[‘InstallDir‘].replace(“\\““/“)
sub_folder = “ArcToolbox/Toolboxes/“
tbx_home = os.path.join(install_dir sub_folder)
msg = ““
passed = True
for a_tbx in toolboxes:
try:
tbx = tbx_home + a_tbx
gp.AddToolbox(tbx)
msg = msg + “\n Adding toolbox: “ + str(tbx)
except:
msg = msg + “\n The toolbox: “ + str(tbx) + \
“\n could not be loaded. Check your toolbox path “ + \
“\n and availability edit BoundingContainers.py to “ + \
“\n reflect its location.“
passed = False
return [gp msg passed]
#--------------------------------------------------------------------
#Import the standard modules and the geoprocessor
#
import os sys string #common examples
#Get the input feature class optional fields and the output filename
inFC = sys.argv[1]
inField = sys.argv[2]
theFName = sys.argv[3]
outFolder = sys.argv[4]
gp gp_version = gp_create(10.0)
gp.AddMessage(“version “ + str(gp_version))
gp msg passed = gp_toolboxes([“Data Management Tools.tbx“] gp gp_version)
gp.AddMessage(msg)
if not passed:
gp.AddMessage(“\n Exiting ..... \n“)
del gp
sys.exit()
#gp.OverWriteOutput = 1
gp.env.overwriteOutput = True
#
desc = gp.Describe
theType = desc(inFC).ShapeType
FullName = desc(inFC).CatalogPath
thePath = (os.path.split(FullName)[0]).replace(“\\““/“)
if theFName != “#“:
theFName = theFName.replace(“ ““_“)
else:
t
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6493 2020-03-31 13:54 按属性分割图层\Splitla
文件 28160 2020-03-31 13:54 按属性分割图层\Splitla
目录 0 2020-09-22 16:16 按属性分割图层\
- 上一篇:120个微信小程序
- 下一篇:基于遗传算法的BP神经网络优化算法
评论
共有 条评论