GridDist - ObjectVision/GeoDMS GitHub Wiki
Grid functions griddist
The griddist is a collection of functions, used to calculate the distances in a grid.
The basic variant is griddist(impedanceGrid: raster->Float, pointset_raster_rel: pointset->raster). Multiple variants are available, see the syntax topic.
- griddist(impedanceGrid: raster->Float, pointset_raster_rel: pointset->raster)
- griddist_maximp(impedanceGrid: raster->Float, pointset_raster_rel: pointset->raster, maxImp: Float)
- griddist_zonal(impedanceGrid: raster->Float, pointset_raster_rel: pointset->raster, zonalGrid: raster->UInt16, boundaryImp: Float)
- griddist_zonal_maximp(impedanceGrid: raster->Float, pointset_raster_rel: pointset->raster, zonalGrid: raster->UInt16, boundaryImp: Float, maxImp: Float)
Where each variant:
- can have an optional additional argument startvalues: pointset->Float, as last argument
- can be suffixed by _untiled and/or
- can be suffixed by _latitude_specific, in that order.
griddist(impedanceGrid, pointset_raster_rel, startvalues) results in an impedance value for each cell of grid which is the lowest accumulated impedance of an eight-connected path towards any point in the pointset. Each step of such a path, from a cell to an adjacent cell, has an impedance of the average of the impedances of both cells, multiplied by the length of the step: 1 for horizontal and vertical steps, sqrt(2) for diagonal steps.
The function can have the following arguments:
- impedanceGrid: raster->nonnegative values, an attribute of a grid domain with an impedance for each cell (e.g. based on slope and/or land use type); negative values are processed as zero;
- pointset_raster_rel: pointset->raster, a relation from a pointset to the raster domain. The pointset contains the locations, from which impedances are calculated. See point 2 grid for how to configure such a relation.
- zonalGrid: raster->UInt16, an attribute of the same grid domain as impedanceGrid with a zone id for each cell; only for the _zonal variants;
- boundaryImp: a parameter with the extra impedance that is added to each step between two cells with a different zonalGrid value; only for the _zonal variants;
- maxImp: a parameter with the maximum impedance; cells for which the resulting impedance would become equal to or larger than maxImp result in null; only for the _maximp variants;
- startvalues: pointset->nonnegative values, the initial impedance values for the point set; can be const(0.0, pointset). Points with a negative start value are ignored.
The resulting values unit is the values unit of the impedanceGrid argument, with a float32 or float64 value type. The values units of the startvalues, boundaryImp and maxImp arguments must match this values unit.
The resulting domain unit is the domain unit of the impedanceGrid argument.
The resulting item contains a subitem TraceBack (UInt4), encoding for each cell the direction of the step by which it was reached.
The griddist function is often used to calculate off-road or future accessibility, where e.g. geophysical factors are assumed to be important factors for assessing accessibility.
The _latitude_specific variants scale the horizontal and diagonal step lengths per grid row, based on the latitude of that row. These variants require the base unit of the grid domain to have a geographic spatial reference.
- The values units of the arguments impedanceGrid, startvalues, boundaryImp and maxImp must match.
- The domain units of the arguments pointset_raster_rel and startvalues must match.
- The domain units of the arguments impedanceGrid and zonalGrid must match.
- The arguments boundaryImp and maxImp must be parameters, i.e. have a void domain.
5.85
O(n log n) where n = number of grid cells. Uses Dijkstra-like algorithm with priority queue for efficient wavefront propagation. Memory usage is proportional to grid size. The _untiled variants process the entire grid at once; tiled variants trade memory for computation overhead at tile boundaries.
- an aspect ratio is required to make griddist useful on a non-square rectangular raster
- a cell-specific (2x2) metric is required to make griddist useful on a generic projection
attribute<GridDomain> GridDomain_rel (destination);
attribute<float64> griddist (GridDomain) := griddist(resistance, GridDomain_rel, const(0.0, destination));
resistance
| 1 | 1 | 1 | 1 | 1 |
| 2 | 3 | 0 | 0 | 1 |
| 2 | 4 | 5 | 1 | 1 |
| 5 | 6 | 3 | 2 | 2 |
| 2 | 2 | 1 | 1 | 1 |
GridDomain, nr of rows = 5, nr of cols = 5
| GridDomain_rel |
|---|
| {1, 1} |
| {1, 3} |
| {4, 1} |
| {4, 4} |
domain destination, nr of rows = 4
griddist
| 1.71 | 0.71 | 0.50 | 0.50 | 0.71 |
| 2.50 | 0 | 0 | 0 | 0.50 |
| 3.54 | 2.83 | 2.50 | 0.50 | 0.71 |
| 4.95 | 4 | 3.33 | 2 | 1.50 |
| 2 | 0 | 1.50 | 1 | 0 |
GridDomain, nr of rows = 5, nr of cols = 5