weeded_counts

Classify functions weeded_counts

syntax

  • weeded_counts(a)

definition

weeded_counts(a) results in a new Domain unit with one entry per distinct value of Data item a, in ascending order, with two [[subitem sub items]]:
  • Values: the distinct values, with the Values unit of a
  • count: how often each occurs, as uint64 (spelled Count in 20.20.0; since 20.21.0 lower case, like the count aggregation function whose name it shares in the case-folded item namespace, so that the old spelling now reports a case mix-up)

Null values are not counted. The number of entries is capped at 4096: above that, adjacent values are merged into one entry whose count is their total, so the result stays a summary of the distribution rather than a full frequency table.

  • a: numeric data item with a Single [[value composition]]

description

This is the value-count table that every Classify functions function calculates internally. Requesting it as a data item of its own is useful when more than one result is derived from the same scan, since the [[calculation cache]] then computes it once. The GeoDMS GUI uses it for the classification it generates for a map layer that has no configured Classification: the number of distinct values determines how many classes the legend gets, and the class breaks are calculated from the same table.

Each of the classify functions has a three argument form that takes such a table instead of the data item, see ClassifyJenksFisher and its siblings on Classify functions.

Below 4096 distinct values the two forms of a classify function give the same class breaks. Above it they can differ, because weeded_counts has merged values that the two argument form counts separately.

applies to

  • data item a with Numeric Value type and [[value composition]] Single

since version

20.20.0

example

unit<uint32> district_counts := weeded_counts(District/NrInh);

unit<uint8>       classes     : nrofrows = 4;
attribute<nrPersons> breaks (classes) :=
    ClassifyNonzeroJenksFisher(district_counts/Values, district_counts/count, classes);
district_counts/Values district_counts/count
0 1
2 1
20 1
55 1
100 1
200 1
300 2
550 1
750 1
860 1
1025 3

Table district_counts, nr of rows = 11, calculated from the 15 rows of table District, one of which is null

see also