logo-header

 
 

syntax

  • diversity(sourcegrid, radius, square_or_circle)

definition

The diversity function is used to find the number of different occurences in the neighbourhood of a cell.

diversity(sourcegrid, radius, square_or_circle) 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 radius is the radius in number of cells, defining the size of the neighbourhood. Constant or parameter square_or_circle indicates if square (value 0) or circle (value 1) 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 uint8 or uint32 value type

Parameters or constants radius and square_or_circle with uint16 value type

conditions

The domain of the sourcegrid attribute must be a Point value type of the group CanBeDomainUnit.

since version

5.15

example

attribute<uint32> diversity (GridDomain) := diversity(sourcegrid, 2w, 1w);
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
GridDomain, nr of rows = 5, nr of cols = 5

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
GridDomain, nr of rows = 5, nr of cols = 5

OBJECT VISION BV
Vrije Universiteit
De Boelelaan 1085
1081 HV Amsterdam
The Netherlands

tel: +31 (0)20 598 9083
fax:+31 (0)20 598 9904