Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.gather

A run read at computed elements: column is read at the element each index names, counted from 0 and held to the run's ends, so an index past either end reads the nearest end. A lookup of a grid cell, a table entry or a neighbour. Built over fieldc.gather: the lookup is part of the chain the consumer evaluates.

Inputs

  • column (Any). The run read: a Column, or a Field over one.
  • index (Any). The element numbers to read, counted from 0: a Field, Column or number.

Outputs

  • field: a field of the column's type.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.gather({ column = g.core.column({ values = { 10, 20, 30 }, type = "Float" }), index = g.element.id }) })

The four points read 10, 20, 30 and 30: the index 3 is held to the last element.