Arc to grid
configuration-examples Arc to grid
This example is used to make a grid representation of an arc, see the figure:
In this figure the red arc is presented in the grid domain, the dark cells are the cells through which the arc passes.
description
A dyna_point function is used to split up the lines in a set of points. Use as distance argument of the dyna_point function half the grid size of the grid domain(or less) if you want all cells passed through by the arc in the grid representation.
An attribute of the arc domain, in this case roadtype, is made available for the segments and the dyna_point domain, in order to be used for the grid.
In the resulting grid three attribute are configured:
- dyna_point_rel: a relation for each grid cell towards the dyna_point domain.
- is_road: an boolean attribute indicating if the cell is passed through by an arc or not. Use this attribute if only this information is needed, as it is using the least memory.
- roadtype: an attribute of the original arc set made available for each cell. As a cell can contain multiple dyna_points, an aggregation method needs to be configured, in this example the modus.
example
container line2grid { unit<uint32> arc: StorageName = "%SourceDataDir/OSM/roads.gpkg", StorageType = "gdal.vect" { attribute<geometries/rdc> geometry (arc) ; attribute<uint8> roadtype; } unit<uint32> segments := arc2segm(arc/geometry) { attribute<uint8> roadtype:= arc/roadtype[sequence_rel]; } unit<uint32> dyna_point := dyna_point_with_ends(segments/point, segments/nextpoint, 50f) { attribute<griddomain_100> griddomain_100_rel := point[griddomain_100]; attribute<uint8> roadtype := segments/roadtype[sequence_rel]; } attribute<dyna_point> dyna_point_rel (griddomain_100) := invert(dyna_point/griddomain_100_rel); attribute<bool> is_road (griddomain_100) := has_any(dyna_point/griddomain_100_rel); attribute<uint8> roadtype (griddomain_100) := modus(dyna_point/roadtype, dyna_point/griddomain_100_rel); }