Relational attribute example
configuration-examples Relational attribute
Relational attributes are used to relate domains. They are use in many calculations, especially in aggregation and relational-functions.
Relational attributes can be made in different ways, two examples that occur often are presented here
example 1, relation based on (external) code attributes
container administrative { unit<uint32> neighborhood : StorageName = "%SourceDataDir%/CBS/2017/neighborhood" , StorageType = "gdal.vect" { attribute<string> municipality_code; attribute<municipality> municipality_rel := rlookup(municipality_code, municipality/values); } unit<uint32> municipality := unique(neighborhood/municipality_code); }
Explanation:
The example presents how an external code can be used to configure a relation. In the example the external code municipality_code is read from a storage. Based on this attribute the municipality domain unit is configured with the unique function. This results in a domain unit with the generated subitem values, containing all unique municipality_codes in alphabetic order.
The resulting relation: municipality_rel attribute, configured with the rlookup values, results in the index-numbers of the municipality domain for the neighborhood domain.
example 2, relation based on geometry (point in polygon)
container bag { unit<uint32> vbo : StorageName = "%SourceDataDir%/BAG/20170101/vbo.shp" , StorageType = "gdal.vect" { attribute<point_rd> geometry; attribute<municipality> municipality_rel := point_in_polygon(geometry, municipality/geometry); } unit<uint32> municipality : StorageName = "%SourceDataDir%/CSB/2017/municipality.shp" , StorageType = "gdal.vect" { attribute<point_rd> geometry (poly); } }
Explanation:
The example presents how a relation can be configured based on a point in polygon relation. In the example the geometry of a vbo (verblijfsobject in the BAG) and the geometry of municipalities are read from storages. The point_in_polygon function results in the index-numbers of the municipality domain for the vbo domain. The relation indicates in which municipality the vbo is located.