I am trying to select the minimum value from a data set being stored in the in_memory
workspace. This prevents me from using sub-queries. I'm hoping that someone has found a work around for this issue or something similar.
-
1Welcome! Please take the tour (gis.stackexchange.com/tour) and update your question to let us know anything that you've tried so far and what results you received/any issues that you are having reaching your goals. Thanks!– MaryBethCommented Dec 14, 2015 at 16:16
Add a comment
|
1 Answer
Try this Python snippet, if you're using ArcGIS 10.1 or later:
fc = 'in_memory/dataset_name'
subquery = ''' YOUR SQL QUERY HERE '''
minval = min(r[0] for r in arcpy.da.SearchCursor(fc, ['FIELD_OF_INTEREST'], subquery))
print minval
-
This would require parsing the field for all rows. Wouldn't Summary Statistics on a layer (with the subquery applied as a definition query) be faster with a large feature class?– VinceCommented Dec 14, 2015 at 18:40
-
I don't see any reason why Summary Statistics would be faster. The
subquery
argument supplied to thewhere_clause
parameter limits the cursor results to only the rows matching the query, which are exactly what Summary Statistics would have to process using your method. Unless I'm misunderstanding? Commented Dec 14, 2015 at 18:45 -
The issue is where the work is done -- in a binary or after processing a list with, say, 100k elements. The I/O cost to write and read should be higher than a read which writes one row, then reading that row.– VinceCommented Dec 14, 2015 at 18:54