Skip to content

Focal statistics

Jip Claassens edited this page Jan 14, 2025 · 1 revision

Calculates for each input cell location a statistic of the values within a specified neighbourhood around it.

In the following example, the local maximum in a 3 km radius is calculated. This is possible for a 'normal' grid domain, but also for a compacted domain. In order to calculate this, you combine the grid domain with a kernel, and then on top of the first and second rel of this combine, you define a 'third_rel,' which can be used as a relation over which you calculate the focal statistic.

unit<uint32> Cdomain_x_pot3k := combine(CompactedDomain, Distmatrices/pot3km/Buffer_NonNull_Cells)
{	
	attribute<domain>          third_rel_d   := ipoint(first_rel -> org_rel) + ipoint(second_rel -> org_rel);
	attribute<CompactedDomain> third_rel     := CompactedDomain/basegrid[third_rel_d];
}

attribute<float32> Current_LocalMaximum (CompactedDomain) := max(CurrState/BuiltUp_Residential_Share[Cdomain_x_pot3k/third_rel], Cdomain_x_pot3k/first_rel); 
Clone this wiki locally