📄 partitionedoverlay.py
字号:
ErStr = "Failure on second try at intersect\n" + str(gp.GetMessages(2))
raise Exception, ErStr
pass
elif errormsg.lower().find(msgEmptyGeometry) >=0:
pass
else:
raise Exception, errormsg
#************************************
#CLIP TOOL
#<input fc> <clip fc> <output fc> <clust tol>
#************************************
elif toolname == "clip_analysis":
try:
input = fctilelist[0]
clip_fc = fctilelist[1]
out_temp = CreateOutTempFCName(os.path.dirname(param_list[2]))
#Run the actual overlay operation on the partitioned feature classes
gp.AddMessage(msgClipping)
gp.clip_analysis(input, clip_fc, out_temp, cluster_tolerance)
for input in fctilelist:
DeleteTempInput(input)
#Do a CreateFeatureClass, but only once. This is the fc to which we append.
if not gp.exists(param_list[2]):
CreatePermanentOutFC(inFC, fcs, param_list[2], out_temp)
#Append out_temp into specified output feature class
gp.AddMessage(msgAppending)
gp.append_management(out_temp, param_list[2])
DeleteTempInput(out_temp)
except:
errormsg = gp.getmessages(2)
if errormsg.find(msgUnexpectedTopoEngine) > 0:
try:
#Run op again to clear topoengine cache in case the reason for failure was a topo engine error.
gp.AddMessage(msgClearCache)
gp.clip_analysis(input, clip_fc, out_temp, cluster_tolerance)
except:
ErStr = "Failed on second try at Clip.\n" + str(gp.getmessages(2))
raise Exception, ErStr
pass
elif errormsg.lower().find(msgEmptyGeometry) >=0:
pass
else:
raise Exception, errormsg
#************************************
#IDENTITY TOOL
#<in_features> <identity_features> <out_feature_class> {NO_FID | ONLY_FID | ALL} {cluster_tolerance} {KEEP_RELATIONSHIPS | NO_RELATIONSHIPS}
#************************************
elif toolname == "identity_analysis":
try:
input_features = fctilelist[0]
identity_fc = fctilelist[1]
if gp.getcount(input_features) <> 0:
out_temp = CreateOutTempFCName(os.path.dirname(param_list[2]))
#Run the actual overlay operation on the partitioned feature classes
gp.AddMessage(msgIdentity)
gp.identity_analysis(input_features, identity_fc, out_temp, param_list[3], cluster_tolerance, param_list[5])
for input in fctilelist:
DeleteTempInput(input)
#Delete any temporary features created during operation that allows attributes to be carried forward.
DeleteTempFeature(out_temp)
#Do a CreateFeatureClass, but only once. This is the fc to which we append.
if not gp.exists(param_list[2]):
CreatePermanentOutFC(inFC, fcs, param_list[2], out_temp)
#Append out_temp into specified output feature class
gp.AddMessage(msgAppending)
gp.append_management(out_temp, param_list[2])
DeleteTempInput(out_temp)
else:
for input in fctilelist:
DeleteTempInput(input)
except:
errormsg = gp.getmessages(2)
if errormsg.find(msgUnexpectedTopoEngine) > 0:
try:
#Run op again to clear topoengine cache in case the reason for failure was a topo engine error.
gp.AddMessage(msgClearCache)
gp.identity_analysis(input, identity_fc, out_temp, param_list[3], cluster_tolerance, param_list[5])
except:
ErStr = "Failure on second try at identity\n" + str(gp.GetMessages(2))
raise Exception, ErStr
pass
elif errormsg.lower().find(msgEmptyGeometry) >=0:
pass
else:
raise Exception, errormsg
#************************************
#UNION TOOL
#<in_features...> <out_feature_class> {NO_FID | ONLY_FID | ALL} {cluster_tolerance} {GAPS | NO_GAPS}
#************************************
elif toolname == "union_analysis":
try:
inputs = ""
for input in fctilelist:
inputs = inputs + ";" + input
out_temp = CreateOutTempFCName(os.path.dirname(param_list[1]))
#Run the actual overlay operation on the partitioned feature classes
gp.AddMessage(msgUnioning)
gp.union_analysis(inputs, out_temp, param_list[2], cluster_tolerance, param_list[4])
for input in fctilelist:
DeleteTempInput(input)
#Delete any temporary features created during operation that allows attributes to be carried forward.
DeleteTempFeature(out_temp)
#Do a CreateFeatureClass, but only once. This is the fc to which we append.
if not gp.exists(param_list[1]):
CreatePermanentOutFC(inFC, fcs, param_list[1], out_temp)
#Append out_temp into specified output feature class
gp.AddMessage(msgAppending)
#QualifyTableName - necessary for sde and debugging
#param_list[1] = QualifyTableNameSDE(param_list[1])
gp.append_management(out_temp, param_list[1])
DeleteTempInput(out_temp)
except:
errormsg = gp.getmessages(2)
if errormsg.find(msgUnexpectedTopoEngine) > 0:
try:
#Run op again to clear topoengine cache in case the reason for failure was a topo engine error.
gp.AddMessage(msgClearCache)
gp.union_analysis(inputs, out_temp, param_list[2], cluster_tolerance, param_list[4])
except:
ErStr = "Failure on second try at union\n" + str(gp.GetMessages(2))
raise Exception, ErStr
pass
else:
raise Exception, errormsg
#************************************
#SYMDIFF TOOL
#<in_features> <update_features> <out_feature_class> {NO_FID | ONLY_FID | ALL} {cluster_tolerance}
#************************************
elif toolname == "symdiff_analysis":
try:
input = fctilelist[0]
update_fc = fctilelist[1]
out_temp = CreateOutTempFCName(os.path.dirname(param_list[2]))
#Run the actual overlay operation on the partitioned feature classes
gp.AddMessage(msgSymDiff)
gp.SymDiff_analysis(input, update_fc, out_temp, param_list[3], cluster_tolerance)
for input in fctilelist:
DeleteTempInput(input)
#Delete any temporary features created during operation that allows attributes to be carried forward.
DeleteTempFeature(out_temp)
#Do a CreateFeatureClass, but only once. This is the fc to which we append.
if not gp.exists(param_list[2]):
CreatePermanentOutFC(inFC, fcs, param_list[2], out_temp)
#Append out_temp into specified output feature class
gp.AddMessage(msgAppending)
gp.append_management(out_temp, param_list[2])
DeleteTempInput(out_temp)
except:
errormsg = gp.getmessages(2)
if errormsg.find(msgUnexpectedTopoEngine) > 0:
try:
#Run op again to clear topoengine cache in case the reason for failure was a topo engine error.
gp.AddMessage(msgClearCache)
gp.SymDiff_analysis(input, update_fc, out_temp, param_list[3], cluster_tolerance)
except:
ErStr = "Failure on second try at union\n" + str(gp.getmessages(2))
raise Exception, ErStr
pass
else:
raise Exception, errormsg
#************************************
#ERASE TOOL
#<in_features> <erase_features> <out_feature_class> {cluster_tolerance}
#************************************
elif toolname == "erase_analysis":
try:
input = fctilelist[0]
erase_fc = fctilelist[1]
out_temp = CreateOutTempFCName(os.path.dirname(param_list[2]))
#Run the actual overlay operation on the partitioned feature classes.
#If nothing exists in the partitioned piece of the erase feature class
#it is ok to simply append the partitioned piece of the input feature class.
gp.AddMessage(msgErasing)
if gp.getcount(erase_fc) > 0:
gp.erase_analysis(input, erase_fc, out_temp, cluster_tolerance)
for input in fctilelist:
DeleteTempInput(input)
else:
out_temp = input
#Do a CreateFeatureClass, but only once. This is the fc to which we append.
if not gp.exists(param_list[2]):
CreatePermanentOutFC(inFC, fcs, param_list[2], out_temp)
#Append out_temp into specified output feature class
gp.AddMessage(msgAppending)
gp.append_management(out_temp, param_list[2])
DeleteTempInput(out_temp)
except:
errormsg = gp.getmessages(2)
if errormsg.find(msgUnexpectedTopoEngine) > 0:
try:
#Run op again to clear topoengine cache in case the reason for failure was a topo engine error.
gp.AddMessage(msgClearCache)
gp.erase_analysis(input, erase_fc, out_temp, cluster_tolerance)
except:
ErStr = "Failure on second try at union\n" + str(gp.getmessages(2))
raise Exception, ErStr
pass
elif errormsg.lower().find(msgEmptyGeometry) >=0:
pass
else:
raise Exception, ErStr
except Exception, ErStr:
raise Exception, str(ErStr)
except:
ErStr = msgFailureInCutItUp + "\n" + str(gp.getmessages(2))
raise Exception, ErStr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -