ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

InsertCursor

  • 描述
  • 讨论
  • 语法
  • 代码示例

描述

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

讨论

旧版本:

自 ArcGIS 10.1 起,此功能已由 arcpy.da.InsertCursor 取代。为了获得更快性能,请使用 arcpy.da.InsertCursor。

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

语法

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

将向其中插入行的表、要素类或 shapefile。

String
spatial_reference

在提供的 spatial_reference 中指定的坐标,并动态转换到数据集的坐标系。

SpatialReference

返回值

数据类型说明
Cursor

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

代码示例

InsertCursor 示例

向表中插入 25 个新行。

import arcpy
# Create insert cursor for table
rows = arcpy.InsertCursor("c:/base/data.gdb/roads_lut")
# Create 25 new rows. Set the initial row ID and distance values
for x in range(1, 26):
    row = rows.newRow()
    row.setValue("rowid", x)
    row.setValue("distance", 100)
    rows.insertRow(row)
# Delete cursor and row objects to remove locks on the data
del row
del rows

相关主题

  • 使用游标访问数据
  • UpdateCursor
  • SearchCursor

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明