Provide more further functionality in the arcpy.da cursors

593
4
11-29-2012 03:50 PM
Status: Open
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.
4 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.