Scalesum - ObjectVision/GeoDMS GitHub Wiki

Rescale functions scalesum

syntax

  • scalesum(proxy, a)
  • scalesum(proxy, relation, a)

definition

  • scalesum(proxy, a) disaggregates the values of parameter a, according to the distribution of the proxy attribute. The function results in a new attribute with the values unit of argument a and the domain unit of argument proxy.
  • scalesum(proxy, relation, a) disaggregates the values of attribute a, according to the distribution of the proxy attribute, grouped by relation. The function results in a new attribute with the values unit of argument a and the domain unit of arguments proxy and relation.

description

To avoid rounding off errors within the scalesum calculation, use a float32 of float64 value type for arguments proxy and a.

The sum of the result will equal the given quantity a, provided that the quantity can be related to any element of the disaggregated domain with a positive proxy value.

To avoid loosing parts of the quantity, check that for each partition the total proxy value is positive (unless the quantity is zero).

conditions

  1. The domain units of arguments proxy and relation must match.
  2. The value type of arguments proxy and a must match.

example

unit<uint32> region : nrofrows = 5
{
    attribute<float32> NrInhabitants: [550, 1025, 300, 200, 0];
}

unit<uint32> city: nrofrows=7
{
    attribute<region> Region_rel : [0, 1, 2, 1, 3, null, 3];
    attribute<float32> NrInhabitants : [550, 525, 300, 500 ,200, 175, null];
    attribute<float32> area : [2, 0, 1, 0 ,1, 1, null];
    attribute<float32> ssum_NrInh := scalesum(NrInhabitants, 550f);
    attribute<uint32> ssum_NrInh_per_region := uint32(scalesum(NrInhabitants, Region_rel, Region/NrInhabitants));
}
City/Area City/NrInhabitants City/Region_rel ssum_NrInh ssum_NrInh_per_region
2 550 0 134.44 550
0 525 1 128.33 525
1 300 2 73.33 300
0 500 1 122.22 500
1 200 3 48.88 200
1 175 null 42.77 null
null null 3 null null

domain City, nr of rows = 7

Region/NrInhabitants
550
1025
300
200
0
⚠️ **GitHub.com Fallback** ⚠️