Point 2 Grid
Configuration examples Point 2 Grid
description
A relation to a Grid Domain can be configured with the value function (example), based on a point Attribute of a vector domain.
The resulting attribute will contain the Index numbers of the related grid domain for the vector domain.
example
// coordinate system
unit<fpoint> rdc_base : SpatialReference = "EPSG:28992";
unit<fpoint> rdc := range(rdc_base, point_yx(300000f,0f), point_yx(625000f,280000f));
// configuration of grid domain, related to the rdc
unit<spoint> griddomain := range(
gridset(rdc, point_yx(-100f, 100f, rdc), point_yx(625000f, 10000f, rdc) ,spoint)
,point_yx( 0s, 0s)
,point_yx(3250s, 2700s)
);
// configuration of vector domain, with a point attribute in rdc coordinates
unit<uint32> vectordomain: nrofrows = 4
{
attribute<rdc> point: [yx(487250, 121350), yx(437450, 92550), yx(455950, 136050), yx(582150, 233950)];
attribute<bool> Ispoint := const(true,.);
}
attribute<griddomain> grid_7015_and_later_rel (vectordomain) := vectordomain/point[griddomain];
// count number of points in grid
attribute<uint32> count_per_griddomain (griddomain) := sum_uint32(vectordomain/Ispoint, grid_7015_and_later_rel);
The example configures a grid domain and a vector domain, both with rdc as their coordinate unit. grid_7015_and_later_rel relates each point to its grid cell, and count_per_griddomain counts the points per cell. The Value conversion works here because both domains express their coordinates in the same unit, rdc.
Between coordinate systems, coordinates are transformed with Convert, with each coordinate system declared in the SpatialReference property of its base unit; see How to configure a coordinate system and Coordinate conversions.
an expression per GeoDMS version
A configuration that must also work in GeoDMS versions without this conversion can choose its expression with the GeoDMSVersion function, which gives the version of the running GeoDMS.
example
attribute<griddomain> grid_rel (vectordomain) := = GeoDmsVersion() > 7.015
? 'vectordomain/point[griddomain]'
: 'value((vectordomain/point - projOffset) / projFactor, griddomain)';
The = after := makes the expression in the example an Indirect expression: depending on the result of GeoDmsVersion, grid_rel is calculated in a different way.