The Data Flow transforms are a category that performs looping functions.
A loop function is a sequence of instructions that repeats until a specific condition is met. Loops are used in programming to solve problems by iterating through a set of steps.
In Giraffe Flows, Data Flow (looping) Transforms iterate over Lists of objects, performing a set of instructions for each item in the list.
Data flow nodes all have the same basic set-up
In a typical single object flow, the object flows in, a node performs a function, and the output is passed out.
In a multi-object list, you need to perform the function on every part of the list.
If we were to pass a list into the apply usage node, we would not get the result we expect, because usages cannot be applied to lists, only features.
The Subdivide node turns the original feature into a feature collection - a list.
To apply the usage to every feature in the list, use the map node. This iterates through the list, and completes the function for each list item.
Here, the list passes into the Map node.
The “value” is each list item.
Each list item has the Usage applied
Then, the result is passed back into the Map node
Finally, the node re-compiles the list to include the resulting geometries.
The index denotes the location of an item in Lists. In Data Flow nodes, the index is a query-able output in the iteration step.
In this example, the index is used to set a random seed in the random color node.
A data flow node using the index as an input
The resulting geometry
Without the random seed, the same random color is assigned to every list item:
No seed
The resulting geometry
Use the index to iterate through specific items in the list or add additional information:
Split lists by odd and/or even indices
Add +1 to each list item by adding the index
Use it to number elements with the marker prop
Use it as a seed for randomness
etc!