diversity
- Details
- Last Updated on Tuesday, 29 January 2013 08:55
syntax
-
diversity(sourcegrid, b, c)
definition
diversity(sourcegrid, b, c) results in a new grid attribute with the number of different values in the neighbourhood of each cell of the sourcegrid attribute.Constant or parameter b is the radius in number of cells, defining the size of the neighbourhood. Constant or parameter c indicates if a circle (value 1) or a square (value 0) is used to define the shape of the neighbourhood. The resulting item has the same domain unit as the sourcegrid attribute and a uint8 or unit32 value type (based on the value type of the sourcegrid attribute).
applies to
Attribute sourcegrid with value types:
- uint8
- uint32
Parameters or constants b and c with value types:
- uint16
conditions
The domain unit of the sourcegrid attribute needs to be of the value type PointGroup and CanBeDomainUnit.
since version
5.15
example
attribute<uint32> diversitygrid(GridDomain)
: expr = "diversity(sourcegrid, uint16(2), uint16(1))";
| sourcegrid | ||||
| null | 0 | 0 | 0 | 1 |
| 0 | 0 | 2 | 1 | 1 |
| 0 | 2 | 3 | 3 | 3 |
| 1 | 1 | 1 | 3 | 0 |
| 0 | 1 | 0 | 1 | 3 |
| diversitygrid | ||||
| 1 | 2 | 4 | 4 | 3 |
| 3 | 4 | 4 | 4 | 4 |
| 4 | 4 | 4 | 4 | 3 |
| 3 | 4 | 4 | 3 | 3 |
| 2 | 3 | 3 | 3 | 3 |