Provide more further functionality in the arcpy.da cursors

724
8
11-29-2012 03:50 PM
Status: Under Consideration
Labels (1)
ChrisSnyder
Regular Contributor III
First off, I absolutely love the .da cursors. Best. Thing. Ever. But, I would love them even more if the included:

1. Some more SHAPE@ keywords (but only if it's faster than getting these properties than using "SHAPE@"
A. SHAPE@EXTENT: Would return a rectangular extent object
B. SHAPE@FIRSTPOINT: point object of the first point of a polyline or polygon
C. SHAPE@LASTPOINT: point object of the last point of a polyline or polygon
2. An optional "spatial filter" parameter.... A polygon object where only features that were in or overlapped the spatial filter would be ruturned by the cursor. Honestly, I would be happy if it used just a rectangualr extent object. I can emulate this using SelectByLocation, but it seems it would be way faster/better if this could be handled as an optional parameter directly in the cursor.
8 Comments
ChrisSnyder
Woops - that title should be "Provide more further functionality in the arcpy.da cursors"
JoshuaBixby
I think past progress on this suggestion is a good indication of future progress, which is too bad because having an optional spatial filter parameter would be much cleaner than having to rely on SelectByLocation.
JohnFannon
The spatial filter parameter is a definite requirement as the existing methods for performing spatial queries are too cumbersome and cannot be efficient.

The spatial filter for cursors in arcpy should follow the same pattern as Esri's other APIs (REST and ArcObjects), which do allow spatial and/or attribute filtering as part of the query. 

 
PaulBrandt

In addition to this idea, I think it would also be useful if a SearchCursor could add or remove the current row from the existing selection set. I find myself building tools to perform custom logic per row with the intent of ending up with a selection set of the rows that meet some advanced criteria. Currently I typically build a list of OID's with a search cursor then go back and select those with the SelectByAttribute tool later, but this is somewhat cludgy, it would be really awesome to be able to have something like rows.selectionAdd() and rows.selectionRemove() which would select or unselect the current row as I cursor through the table.

HannesZiegler
Status changed to: Under Consideration

Thank you for your suggestion for a spatial filter and additional SHAPE@ tokens for the arcpy.da cursors.

We have been working to improve on this area and the spatial filter parameter has been implemented since Pro 3.2 (woops, we missed updating you guys here - sorry about that! 😅).

For full details, see the What's New in ArcGIS Pro 3.2 document as well as arcpy.da.SearchCursor and arcpy.da.UpdateCursor documentations.

 

The idea regarding additional SHAPE@ tokens is not yet implemented but something we are interested in investigating further. For that reason, I am marking this idea under consideration. Note that "under consideration" does not guarantee that the idea will be developed so we encourage the community to continue voting and sharing feedback which will help teams gauge user demand. 

JoshuaBixby

@HannesZiegler, thanks for the update.  I am not sure if there is an existing separate idea or not, but it would be great to add additional Python data structures to what can be used with the ArcPy Data Access cursors.  The default would have to remain the same to maintain compatibility but having a parameter/flag for returning SearchCursor records as named tuples and similar would be great.

Bud
by

@ChrisSnyder 

Woops - that title should be "Provide further functionality in the arcpy.da cursors"

You can edit the post’s title using Post Options > Edit Post.

HannesZiegler

@JoshuaBixby I'm not aware of any existing ideas posted for this. If you are interested in pursuing this idea further, it'd be best to post this suggestion as a separate idea. When writing an idea, it really helps us if you include concrete examples of where and how a proposal would be useful.