arcpy示范教学(一):基本操作

arcpy基本操作

打开目录,遍历目录,打开要素类,遍历要素,打开文件,写入属性值

import arcpy
import codecs

# 设置工作目录
arcpy.env.workspace = 'H:\\'
# 扫描所有数据库
workspaces = arcpy.ListWorkspaces("*", "FileGDB")

# 打开文件
with codecs.open('F:/bou/csv/city.csv','w','utf-8') as f:
# 遍历数据库
    for workspace in workspaces:
# 打开数据表
    with arcpy.da.SearchCursor(workspace +'\\layerName',"*") as cursor:
# 遍历行
        for row in cursor:
            f.write(row[4]+','+row[5][0:4]+'\r\n')

 

转载于:https://www.cnblogs.com/dadream/p/10456476.html

你可能感兴趣的:(arcpy示范教学(一):基本操作)