ArcGIS for Desktop

  • ドキュメント
  • 価格
  • サポート

  • My Profile
  • ヘルプ
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

組織のマッピング プラットフォーム

ArcGIS for Desktop

完全なプロ仕様の GIS

ArcGIS for Server

エンタープライズ GIS

ArcGIS for Developers

位置情報利用アプリの開発ツール

ArcGIS Solutions

各種業界向けの無料のテンプレート マップおよびテンプレート アプリケーション

ArcGIS Marketplace

組織で使えるアプリとデータを取得

  • ドキュメント
  • 価格
  • サポート
Esri
  • サイン イン
user
  • マイ プロフィール
  • サイン アウト

Help

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • その他...

Cursor

  • サマリ
  • メソッドの概要
  • メソッド
  • コードのサンプル

サマリ

A cursor is a data access object that can be used either to iterate through the set of rows in a table or to insert new rows into a table. Cursors have three forms: search, insert, or update. Cursors are commonly used to read and update attributes.

メソッドの概要

メソッド説明
deleteRow (row)

Deletes a row in the database. The row corresponding to the current position of the cursor will be deleted.

insertRow (row)

Inserts a new row into the database.

newRow ()

Creates an empty row object.

next ()

Returns the next object at the current index.

reset ()

Sets the current enumeration index (used by the next method) back to the first element.

updateRow (row)

The updateRow method can be used to update the row at the current position of an update cursor.

メソッド

deleteRow (row)
パラメータ説明データ タイプ
row

The row to be deleted.

Row
insertRow (row)
パラメータ説明データ タイプ
row

The row to be inserted.

Row
newRow ()

戻り値

データ タイプ説明
Row

A new empty row object.

next ()

戻り値

データ タイプ説明
Object

The next object at the current index.

reset ()
updateRow (row)
パラメータ説明データ タイプ
row

The row used to update the current position of the cursor.

Row

コードのサンプル

Cursor example 1

Use search cursor to view field values in row.

import arcpy

# Set the workspace
arcpy.env.workspace = "c:/base/data.gdb"

# Create the search cursor
cursor = arcpy.SearchCursor("roads", '"TYPE" <> 4')

# Iterate through the rows in the cursor
for row in cursor:
    print("Name: {0},  CFCC code: {1}".format(row.NAME, row.CFCC))

del cursor, row
Cursor example 2

Use an update cursor to change field values in rows.

import arcpy

# Set the workspace
arcpy.env.workspace = "c:/base/data.gdb"

# Create the update cursor
cursor = arcpy.UpdateCursor("roads")

# Update the road buffer distance field based on road type.
#   Road type is either 1,2,3,4  Distance is in meters.
for row in cursor:
    row.setValue("BUFFER_DIST", row.getValue("TYPE") * 100)
    cursor.updateRow(row)

# Delete cursor and row objects
del cursor, row
Cursor example 3

Use an insert cursor to create new rows in table.

import datetime
import arcpy

# Create insert cursor for table
cursor = arcpy.InsertCursor("c:/base/data.gdb/roads_maint")

# Create 25 new rows. Set default values on distance and CFCC code
for i in range(1000, 1025):
    row = cursor.newRow()
    row.setValue('rowid', i)
    row.setValue('distance', 100)
    row.setValue('CFCC', 'A10')
    row.setValue('LastInsp', datetime.datetime.now())
    cursor.insertRow(row)

# Delete cursor and row objects
del cursor, row

関連トピック

  • Row
  • カーソルを使用したデータへのアクセス
  • カーソルの空間参照の設定
このトピックへのフィードバック

ArcGIS for Desktop

  • ホーム
  • ドキュメント
  • 価格
  • サポート

ArcGIS プラットフォーム

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

Esri について

  • 会社概要
  • 採用情報
  • スタッフ ブログ
  • ユーザ カンファレンス
  • デベロッパ サミット
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | プライバシー | リーガル