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')

 

posted @ 2019-03-01 15:04  sulerzh  阅读(2389)  评论(0编辑  收藏  举报