1

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.

1
  • 1
    Welcome! 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!
    – MaryBeth
    Commented Dec 14, 2015 at 16:16

1 Answer 1

2

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
3
  • 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?
    – Vince
    Commented Dec 14, 2015 at 18:40
  • I don't see any reason why Summary Statistics would be faster. The subquery argument supplied to the where_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?
    – nmpeterson
    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.
    – Vince
    Commented Dec 14, 2015 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.