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