ArcGIS Python获得岛的个数

import arcpy
def getpnum(geometry):
    part_count = geometry.partCount
    if part_count>1:#多部件
        return  999999 
    geo=geometry.getPart(0)
    num=geo.count
    n=0    
    for i in range(num):
        pt=geo[i]
        if pt==None: #空点就是下一个内多边形
            n=n+1     
    return n
inFeature= arcpy.GetParameterAsText(0)
fieldname= arcpy.GetParameterAsText(1)
with arcpy.da.UpdateCursor(inFeature, [fieldname,"shape@"]) as cursor:
    for row in cursor:
        k=getpnum(row[1])
        arcpy.AddMessage("k:"+str(k))
        row[0] =k
        cursor.updateRow(row)
#rows = arcpy.UpdateCursor(inFeature)
#for row in rows:
    
#    row.setValue(fieldname, getpnum(row.getValue("shape")) )
#    rows.updateRow(row)

#del row
#del rows
  

 

上一篇:关于python连接阿里云数据库


下一篇:python-连接数据库pymysql