ArcPy函数-插入游标InsertCursor


ArcGIS 帮助 10.2

摘要

向要素类、shapefile 或表中插入行。InsertCursor 返回一个分发行对象的枚举对象。

讨论

可使用 newRow 方法从插入行的枚举对象获取新的行对象。每次调用光标上 insertRow 都会在表中创建新行,该行的初始值设置为输入行中的值。

语法

InsertCursor (dataset, {spatial_reference})
参数 说明 数据类型
dataset

The table, feature class, or shapefile into which rows will be inserted.

String
spatial_reference

Coordinates are specified in the spatial_reference provided and converted on the fly to the coordinate system of the dataset.

SpatialReference
返回值
数据类型 说明
Cursor

返回针对指定要素类、shapefile 或表的光标对象。

代码实例

InsertCursor 示例

向表中插入 25 个新行。

 1 import arcpy
 2 
 3 # Create insert cursor for table
 4 rows = arcpy.InsertCursor("c:/base/data.gdb/roads_lut")
 5 
 6 # Create 25 new rows. Set the initial row ID and distance values
 7 for x in xrange(1, 26):
 8     row = rows.newRow()
 9     row.setValue("rowid", x)
10     row.setValue("distance", 100)
11     rows.insertRow(row)
12 
13 # Delete cursor and row objects to remove locks on the data
14 del row
15 del rows

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM