查找MDB中高程点的高程值有0值的图幅(用游标遍历查找某个字段的值),并将查到的结果写入到TXT中...

1、
mdbs = arcpy.ListWorkspaces("*","Access")

2、
 FeatureClasses = arcpy.ListFeatureClasses()

3、
Fields = arcpy.ListFields(FeatureClass)
4、
cursor = arcpy.da.SearchCursor(FeatureClass, 'ELEV')


注意:工作空间的转换

 

 
  
import arcpy
from arcpy import env
import os
#input = r"E:\test\MDB"
input = arcpy.GetParameterAsText(0)
env.workspace = input
mdbs = arcpy.ListWorkspaces("*","Access")
for mdb in mdbs:
    #a = ""
    cout = 0
    mdbname = mdb[-14:-4]
    #print mdbname
    env.workspace=mdb
    FeatureClasses = arcpy.ListFeatureClasses()
    for FeatureClass in FeatureClasses:
        if "TERP" in FeatureClass:
            #print FeatureClass
            Fields = arcpy.ListFields(FeatureClass)
            for Field in Fields:
                fieldname = Field.name
                #print fieldname
                if "ELEV" in fieldname:
                    cursor = arcpy.da.SearchCursor(FeatureClass, 'ELEV')
                    for row in cursor:
                        #print(row)
                        if row[0] == 0:
                            #a = mdbname
                            cout = cout+1
                    if cout > 0:
                        arcpy.AddMessage(mdbname+" "+"dgx Elev have 0 problem!")
                        textpath = input+os.sep+"text.txt"
                        f = open(textpath,"a")
                        f.write(mdbname+'\n')
                        f.close()
                        
                            
   # print cout
   # f = open("E:/test/text.txt","a")
    #f.write(a+'\n')
    #f.close()


                    
                

        
 
  

 

 

 

转载于:https://www.cnblogs.com/gistwz/p/10265676.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值