赞
踩
一、功能介绍
二、脚本代码
大部分代码引用自https://www.cnblogs.com/geozho/p/10167957.html
# -*- coding: utf-8 -*- import arcpy import os # Script arguments in_rasters = arcpy.GetParameterAsText(0) in_dbf = arcpy.GetParameterAsText(1) out_csv = arcpy.GetParameterAsText(2) arcpy.AddMessage(in_rasters) # Local variables: out_dbf = in_rasters arcpy.RasterToGeodatabase_conversion(in_rasters, in_dbf, "") ws = in_dbf arcpy.env.workspace = ws rasters = arcpy.ListRasters("*") for raster in rasters: rasloc = ws + os.sep + raster fields = "*" try: lstFlds = arcpy.ListFields(rasloc) header = '' header += ",{0}".format(lstFlds[0].name)+",{0}".format(lstFlds[1].name) if len(lstFlds) != 0: f = open(out_csv, 'a') header = header[0:] + ',RasterName\n' f.write(header) with arcpy.da.SearchCursor(rasloc, fields) as cursor: for row in cursor: f.write(str(row).replace("(", "").replace(")", "") + "," + raster + '\n') f.close() except Exception as e: print (e) del row
三、工具参数
新建一个地理数据库步骤如下图:
四、工具界面
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。