Exploring data
- What's there:
list_layersgives every layer's fields, feature count and selection.layer.fieldsdescribes one layer's fields in detail. - Rows: use
read_featureswithfields(only the ones you need),where(pop_max > 1000000 AND continent = 'Asia'),order_bywithdescending, and a smalllimit. The reply gives the number of matching rows, so you don't need to read them all to count. - Statistics: for sums, means, medians, percentiles, most common values or counts by category, use the
summaryStatisticstool (describe_toolfor its parameters, thenrun_tool). One call can group by severalcasefields (["county", "year"]) and compute several statistics (statistics, a list of{"field", "statistic"}). Its output is a standalone table, which the result names: read it withread_features(table), and sort it withorder_byto find the largest group.FREQUENCYis each group's record count. - Cross-tabulations ("by county and year", one field's values side by side): use the
pivotTabletool, withfieldsfor the rows,pivotfor the field whose values become columns,value, and astatisticsuch asMEANorCOUNTwhen several records share a row and column. Read its table withread_features. - Showing the answer on the map:
select.byAttributeswith the samewhere, thenselect.zoomTo. A lasting filter islayer.definitionQuery; tell the user, because it hides the other features until it's cleared. - Spatial questions ("within 50 km of", "inside"): use the
selectByLocationtool, orbufferand thenclip.
Report numbers exactly as read, with units if the field name or values give them. Never estimate what you can read. If a field's meaning is unclear, say what you assumed.