Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.raster.blend (procNode)

Blend a value into one layer of a raster, cell by cell, by a weight, over every cell the tiles hold (the cells of the field, the cells of a border tile past it and the ring around the tiles): replace, add, take the greater or lesser, or multiply.

Built from g.field.substitute (the cell position into value and weight, each held cell at its own position) and the grid kernel in write mode over the raster's tile layout (MODE = write, BLEND = mode), the patch window starting apron cells before the field's first cell and spanning heldX by heldZ. Every tile that holds a cell, as core or as apron, receives it, so the aprons agree. The weight scales how much of the value is blended in: 0 leaves the cell alone and 1 applies the mode in full.

Inputs

  • raster (Raster). The raster written.
  • layer (String). Default "height". The layer written.
  • value (Value). Default 0.0. What is blended in, per cell: a number, a column over the held cells (core.raster.read with held) or a field of the cell's position, written over the position leaf g.element.P (value = g.element.P.x is the cell's x).
  • weight (Value). Default 1.0. How much of the value applies per cell, 0 to 1: a number, a column over the held cells or a field over g.element.P.
  • mode (one of replace, add, max, min, multiply). Default "replace". How the value meets the cell: replaces it, is added to it, or the greater, the lesser or the product of the two is kept.

Outputs

  • raster: the raster with the layer written.

Example

local raster = g.core.raster.new({ size = { x = 8, z = 8 }, resolution = 1, layers = { "height" } })
local raised = g.core.raster.blend({ raster = raster, layer = "height", value = 2.0, weight = 0.5, mode = "add" })
local total = g.core.raster.reduce({ raster = raised, layer = "height", op = "max" })

Half of 2 is added to every cell: total is 1.