您的位置:首页 > 编程语言 > Python开发

注释一段GP工具中Python脚本(读取表中字段信息)

2009-05-20 11:06 549 查看
# ---------------------------------------------------------------------------

# Iterate Field Value.py

# ---------------------------------------------------------------------------

# Import system modules

import sys, string, os, arcgisscripting

# Create the Geoprocessor object

gp = arcgisscripting.create()

# Set the parameters.

# Input feature class or table for which the value has to be read from a field

inputTable = gp.GetParameterAsText(0)

if (inputTable == ''):

gp.AddError("No input table provided")

raise "No input table provided"

# The desired field for which the values will be read

inputField = gp.GetParameterAsText(1) #你要检索的字段 手动输入

if (inputField == ''):

gp.AddError("No input field provided")

raise "No input field provided"

# Setting value to increment the iteration number for next row in the table

index = int(gp.GetParameterAsText(2))# 让你的迭代次数和对表的索引号一致

# Insert Search Cursor

value = "0" #初始化输出值

bContinue = "false"

currentRow = 0

cur = gp.SearchCursor(inputTable) #开始扫描表

row = cur.Next()# 跳过表头 进入下一行

while row:

if (index == currentRow):#判断行号和索引是否一致

value = row.getValue(inputField)#获取该行 该字段中的值

bContinue = "true" # 把进行一下步的预处理设为真

break

row = cur.Next()

currentRow = currentRow + 1 #开始进入下次循环

del cur

gp.SetParameterAsText(3, str(value))

gp.SetParameterAsText(4, str(bContinue))# 输出
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: