Skip to main content

Attribute Create

Create or overwrite one attribute from an expression.

Syntax​

{ "id": "n1", "op": "attribute", "name": "attribute", "x": 0, "y": 0, "params": {} }

An edge into it ends at "targetPort": "in"; one out of it starts at "sourcePort": "out".

Inputs​

PortTypeTakes
intableone edge

Parameters​

ParameterKindDefaultChoices
namestring"value"
expressionexpr"0.0"

Outputs​

PortType
outtable

Remarks​

Attribute Create adds a column, or replaces one, computed from an expression over the row's other columns: [lng, lat] makes a position, sqrt(pop) * 2 a size. It is how a layer gets a per-row value; there are no accessor functions. Older projects' Accessor operators convert to it.

The expression compiles to SQL, to a CPU loop or to a GPU shader, whichever the planner finds cheapest for where its value goes. A parameter it reads with ch('node/param') is bound, not written into the expression, so dragging that parameter does not recompile the graph.

The name is the column's: letters, digits and underscores, starting with a letter or an underscore. A layer reads it by that name, as in a Scatterplot Layer's position.

Examples​

A size from a magnitude column, scaled by a slider:

{
"nodes": [
{ "id": "n1", "op": "number", "name": "scale", "x": 0, "y": 200, "params": { "value": 2 } },
{ "id": "n2", "op": "attribute", "name": "size", "x": 300, "y": 0, "params": { "name": "size", "expression": "sqrt(mag) * ch('scale/value')" } }
],
"edges": []
}

Details​

  • Category: Rows
  • Operator: attribute

Older projects​

Projects saved before documents used operator classes. These convert to attribute when they open: AccessorOp, DateFormatOp, DateMathOp, DatePartsOp.