A cursor is a data access object that can be used to either iterate over the set of rows in a table or insert new rows into a table. Cursors have three forms: search, insert, update and delete rows, while an insert cursor is used to insert rows into a table or feature class.
Vorversion:.
Hinweis:
Cursors honor layer and can be iterated with a for loop. The next row can also be accessed by explicitly using i in range(0,25): cursor.insertRow([i,, from the cursor, it is returned as a list of field values that correspond by index position.
In the sample below, state name and population count('{} has a population of {}'.format(row[0], row[1]))
Tipp: ID field, which may have many names depending on the data type. Simple feature classes require a geometry field, typically (but not always) named Shape. The OID@ token can be used to access the object ID field, and the SHAPE@ token (which returns a geometry object) can be used to access the geometry field of a feature class without having prior knowledge of the field names.
import arcpy
infc = arcpy.GetParameterAsText(0)
# Enter for loop for each feature
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@"]):
# Print the current multipoint's ID
print("Feature {}:".format(row[0]))
# For each point in the multipoint feature,
# print the x,y coordinates
for pnt in row[1]:
print("{}, {}".format(pnt.X, pnt.Y)).
More information on some specific field types is described below.('a', ['guid_field']) id = uuid.uuid1() ic.insertRow([id])
Add a record with a GUID field using a string.
import arcpy ic = arcpy.da.InsertCursor('a', [('a', ['date_field']) date_value = datetime(2020, 7, 1, 12, 30) ic.insertRow([date_value])
Add a record with a date field using a string value.
import arcpy ic = arcpy.da.InsertCursor('a', ['date_field']) date_value = "July 1 2020 12:30) ic.insertRow([date_value])
BLOB fields
A binary large object .
Feedback zu diesem Thema?