Cursor¶
Cursor Helper module
| CLASS | DESCRIPTION |
|---|---|
Field |
Field Representation |
InsertOptions |
Optional parameters for InsertCursors |
SQLClause |
Wrapper for Cursor sql_clause attribute, |
SearchOptions |
Optional parameters for SearchCursors |
UpdateOptions |
Optional parameters for UpdateCursors |
WhereClause |
Wraps a string clause to signal to FeatureClass/Table indexes that a Where Clause is being passed |
| FUNCTION | DESCRIPTION |
|---|---|
convert_field |
Convert an arcpy Field object to a Field argument dictionary |
get_field_type |
Convert a field type flag from a describe arcpy.Field to arguments for AddField |
Field
¶
Bases: TypedDict
Field Representation
| ATTRIBUTE | DESCRIPTION |
|---|---|
field_type |
The type of the field (required)
TYPE:
|
field_precision |
The precision (digits) of numeric fields (default: database determined)
TYPE:
|
field_scale |
The number of decimal places for floating point fields (default: database determined)
TYPE:
|
field_length |
The maximum character count for
TYPE:
|
field_alias |
Human readable alias for fields with confusing internal names (optional)
TYPE:
|
field_is_nullable |
Allow null values (default:
TYPE:
|
field_is_required |
Field requires a value to be set (default: False)
TYPE:
|
field_domain |
Existing Domain name to bind to field (optional)
TYPE:
|
- Modules
SQLClause
¶
Bases: NamedTuple
Wrapper for Cursor sql_clause attribute,
| ATTRIBUTE | DESCRIPTION |
|---|---|
prefix |
The SQL prefix to be prepended to the
TYPE:
|
postfix |
The SQL postfix that will be appended to the
TYPE:
|
Format
SELECT {prefix} {fields} FROM {table} WHERE {where_clause} {postfix}
Usage
>>> five_longest = SQLClause(prefix='TOP 5', postfix='ORDER BY LENGTH DESC')
>>> fc_result = feature_class.get_tuples(('NAME', 'LENGTH'), sql_clause=five_longest))
>>> print(list(fc_result))
[('foo', 1001), ('bar', 999), ('baz', 567), ('buzz', 345), ('bang', 233)]
- Modules FeatureClass
- Modules FeatureClass
SearchOptions
¶
Bases: TypedDict
Optional parameters for SearchCursors
| ATTRIBUTE | DESCRIPTION |
|---|---|
where_clause |
A SQL query that is inserted after the SQL
TYPE:
|
spatial_reference |
Perform an on the fly projection of the yielded geometry to this reference |
explode_to_points |
Return a row per vertex in each feature (e.g.
TYPE:
|
sql_clause |
A tuple of SQL queries that is inserted after the SQL
TYPE:
|
datum_transformation |
The transformation to use during projection if there is a datum difference between the feature projection and the
target SpatialReference (you can use
TYPE:
|
spatial_filter |
A shape that will be used to test each feature against using the specified
TYPE:
|
spatial_relationship |
The type of relationship with the
TYPE:
|
search_order |
Run the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
A dictionary with the populated keys |
Usage
>>> options = SearchOptions(where_clause='OBJECTID > 10')
>>> not_first_ten = feature_class.get_tuples(['NAME', 'LENGTH'], **options)
>>> print(list(not_first_ten))
[('cleese', 777), ('idle', 222), ('gilliam', 111), ...]
WhereClause
¶
WhereClause(
where_clause: str, skip_validation: bool = False
)
Wraps a string clause to signal to FeatureClass/Table indexes that a Where Clause is being passed
Object for storing and validating where clauses
| PARAMETER | DESCRIPTION |
|---|---|
|
The where clause that you want to pass to a FeatureClass
TYPE:
|
|
Skip the validation step (default: False)
TYPE:
|
-
Modules
FeatureClass
where
| METHOD | DESCRIPTION |
|---|---|
get_fields |
Sanitize a where clause by removing whitespace |
validate |
Check to see if the clause fields are in the fields list |
Source code in src/arcpie/cursor.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_fields
¶
Sanitize a where clause by removing whitespace
Source code in src/arcpie/cursor.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
validate
¶
Check to see if the clause fields are in the fields list
| PARAMETER | DESCRIPTION |
|---|---|
|
The fields to check against |
Source code in src/arcpie/cursor.py
121 122 123 124 125 126 127 | |
convert_field
¶
Convert an arcpy Field object to a Field argument dictionary
| PARAMETER | DESCRIPTION |
|---|---|
|
The Field object returned by Describe().fields
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Field
|
A Field argument dictionary that can be used to construct a new field |
Source code in src/arcpie/cursor.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
get_field_type
¶
get_field_type(
arc_field_type: FieldType, *, strict: bool = False
) -> FieldType
Convert a field type flag from a describe arcpy.Field to arguments for AddField
| PARAMETER | DESCRIPTION |
|---|---|
|
The field type as reported by arcpy.Describe(...).fields
TYPE:
|
|
Raise a ValueError if this is set to True, otherwise assume
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FieldType
|
(FieldType) |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/arcpie/cursor.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |