arcgis.features.Table.query Inputs

02-19-2018 05:31 PM
New Contributor II

I'm trying to return the maximum value from a field in a table, or better yet the maximum value for the field when grouped on another field. I know how to write the SQL for this, but I'm fairly new to ArcGIS, and I'm at a loss on how to translate this into the input parameters for the query() function. It looks like I need to use the parameters 'group_by_fields_for_statistics' and 'out_statistics', but I can't find any examples on what these should actually look like.

The API reference is not much help; for out_statistics, it says, "The definitions for one or more field-based statistics to be calculated." Does that mean a string with a sql function ("MAX" or "MAX()" or "MAX(fieldname)" or...?), a function definition, a predefined list of functions somewhere that I need to invoke, or something else entirely? 

This isn't the first time I've run into this kind of issue with arcgis (that is, finding that an input parameter is available but being unable to find any guidance on how to use it), so if there's a good reference or resource for this that I'm just missing, I'd be very glad to hear about it.

0 Kudos
1 Reply
MVP Esteemed Contributor

The Python group is older and generally for ArcPy questions.  I am sharing with the ArcGIS API for Python‌ group.

Overall, the ArcGIS API for Python is a Python wrapper for ArcGIS REST API.  That said, they do continue to add unique functionality outside of the REST API.  For understanding more about the query syntax, see Query (Map Service\Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developers  .

What you are looking for is how to call Summarize Attributes—ArcGIS REST API: Services Directory | ArcGIS for Developers using the ArcGIS API for Python.  Right off the top, I am not sure, I will have to dig into the Python documentation more and get back with you.