|
in_table
|
The feature class, layer, table, or table view.
|
String
|
|
field_names
[field_names,...]
|
A list (or tuple) of field names. For a single field, you can use a string instead of a list of strings.
Use an asterisk (
*
) instead of a list of fields to access all fields from the input table (BLOB fields are excluded). However, for faster performance and reliable field order, it is recommended that the list of fields be narrowed to only those that are actually needed.
Additional information can be accessed using tokens (such as
OID@
) in place of field names:
-
ANNO@
—
An
Annotation
object for
the feature. This option is only valid for
ArcGIS Pro
annotation feature classes
.
-
SHAPE@XY
—
A tuple of the feature's centroid x,y coordinates.
-
SHAPE@XYZ
—
A tuple of the feature's centroid x,y,z coordinates.
-
SHAPE@TRUECENTROID
—
A tuple of the feature's centroid x,y coordinates. This returns the same value as
SHAPE@XY
.
-
SHAPE@X
—
A double of the feature's x-coordinate.
-
SHAPE@Y
—
A double of the feature's y-coordinate.
-
SHAPE@Z
—
A double of the feature's z-coordinate.
-
SHAPE@M
—
A double of the feature's m-value.
-
SHAPE@JSON
—
The
Esri
JSON string representing the geometry.
-
SHAPE@WKB
—
The well-known binary (WKB) representation for OGC geometry. It
provides a portable representation of a geometry value as a
contiguous stream of bytes.
Values are returned as a
bytearray
object.
-
SHAPE@WKT
—
The well-known text (WKT) representation for OGC geometry. It
provides a portable representation of a geometry value as a text
string.
-
SHAPE@
—
A
geometry
object for the feature.
-
SHAPE@AREA
—
A double of the feature's area.
-
SHAPE@LENGTH
—
A double of the feature's length.
-
CREATED@
—
A datetime object of when the feature was created. This field is read-only.
-
CREATOR@
—
A string of the username that created the feature. This field is read-only.
-
EDITED@
—
A datetime object of when the feature was last edited. This field is read-only.
-
EDITOR@
—
A string of the username that last edited the feature. This field is read-only.
-
GLOBALID@
—
A string of the universal unique identifier of the feature. This field is read-only.
-
OID@
—
The value of the Object ID field.
-
SUBTYPE@
—
An integer of the subtype code.
|
String
|
|
where_clause
|
An optional expression that limits the records returned. For more information on WHERE clauses and SQL statements, see
SQL reference for query expressions used in ArcGIS
.
(The default value is None)
|
String
|
|
spatial_reference
|
The spatial reference of the feature class. When this argument is specified, the feature will be projected (or transformed) from the input's spatial reference. If unspecified, the input feature classes' spatial reference will be used. Valid values for this argument are a
SpatialReference
object or string equivalent.
If a spatial reference is specified, but the input feature class has an unknown spatial reference, neither a projection nor transformation can be completed. The geometry returned by the cursor will have coordinates matching the input, with a spatial reference updated to the one specified.
(The default value is None)
|
SpatialReference
|
|
explode_to_points
|
Deconstruct a feature into its individual points or vertices. If
explode_to_points
is set to
True
, a multipoint feature with five points, for example, is represented by five rows.
(The default value is False)
|
Boolean
|
|
sql_clause
|
A pair of SQL prefix and postfix clauses organized in a list or tuple.
An SQL prefix clause supports
None
,
DISTINCT
, and
TOP
. An SQL postfix clause supports
None
,
ORDER BY
, and
GROUP BY
.
Use
DISTINCT
in a prefix clause.
with arcpy.da.SearchCursor(
in_features,
["OID@", "STREET_NAME"],
sql_clause=("DISTINCT STREET_NAME", None)
) as cur:
Use
TOP
in a prefix clause, and
ORDER BY
in a postfix clause.
with arcpy.da.SearchCursor(
in_features,
['OID@', "ELEVATION"],
sql_clause=("TOP 5", "ORDER BY ELEVATION DESC")
) as cur:
Use
GROUP BY
in a postfix clause.
with arcpy.da.SearchCursor(
in_features,
['STREET_NAME'],
sql_clause=(None, "GROUP BY STREET_NAME")
) as cur:
An SQL prefix clause is positioned in the first position and will be inserted between the
SELECT
keyword and the
SELECT COLUMN LIST
. The SQL prefix clause is most commonly used for clauses such as
DISTINCT
or
ALL
.
An SQL postfix clause is positioned in the second position and will be appended to the
SELECT
statement, following
the where clause. The SQL postfix clause is most commonly used for clauses such as
ORDER BY
.
DISTINCT
,
ORDER BY
, and
ALL
are only supported when working with
databases. They are not supported by other data sources (such as dBASE or INFO tables).
TOP
is only supported by
SQL Server
databases.
(The default value is (None, None))
|
tuple
|
|
datum_transformation
|
When the cursor projects the features from one spatial reference to another, if the spatial references do not share the same datum, an appropriate datum transformation should be specified.
The
ListTransformations
function can be used to provide a list of valid datum transformations between two spatial references.
Learn more about datum transformations
(The default value is None)
|
String
|
|
spatial_filter
|
A geometry object used to spatially filter features. When this argument is specified, the cursor will limit the features returned, based on specified geometry and the
spatial_relationship
value.
(The default value is None)
|
Geometry
|
|
spatial_relationship
|
The spatial relationship between the input and the query geometry in the
spatial_filter
argument. This argument is only applicable when specifying the
spatial_filter
argument.
-
INTERSECTS
—
Rows are only returned when the
spatial_filter
geometry intersects the input row's geometry.
-
ENVELOPE_INTERSECTS
—
Rows are only returned when the
spatial_filter
geometry's envelope intersects the input row's geometry.
-
INDEX_INTERSECTS
—
Rows are only returned when the
spatial_filter
geometry's envelope intersects the index entry for the input row's geometry. Because it uses the underlying index grid, rather than the envelope of the feature, it is faster and is commonly used for return features for display purposes.
-
TOUCHES
—
Rows are only returned when the
spatial_filter
geometry touches the input row's geometry.
-
OVERLAPS
—
Rows are only returned when the
spatial_filter
geometry overlaps the input row's geometry.
-
CROSSES
—
Rows are only returned when the
spatial_filter
geometry crosses the input row's geometry.
-
WITHIN
—
Rows are only returned when the
spatial_filter
geometry is within the input row's geometry.
-
CONTAINS
—
Rows are only returned when the
spatial_filter
geometry contains the input row's geometry.
(The default value is INTERSECTS)
|
String
|
|
search_order
|
The order in which the spatial searches are applied by the RDBMS. This property only affects enterprise geodatabase data and is only applicable when specifying the
spatial_filter
argument.
-
ATTRIBUTEFIRST
—
The attribute query will be applied first.
-
SPATIALFIRST
—
The spatial query will be applied first.
(The default value is ATTRIBUTEFIRST)
|
String
|