Cut by layer and append value

I want to cut a polygon with another polygon similar to this example in the intermediate tutorial
https://riskscape.org.nz/docs/_images/cut_layer.svg

I have two questions
How can I do this using a pipeline rather than a wizard?

and

Once the cut has happened are the values of the cutting layer applied to the cut layer. EG in the above image does the line segment A get the value ‘green’ and does the line segment B get the value ‘blue’

Hi John,

I think the simplest way would be to go through the first few geoprocessing questions in the wizard, then use the pipeline it generates (you can use the CTRL+C menu to view the pipeline at any point in the wizard). That’s what I usually do.

One thing to note is that the layer_intersection expects a bookmark argument, so if you have multiple features in your other layer, but only want to cut against one of them, adding a bookmark filter can be handy.

With merging the attributes, the wizard should guide you through that. But you can also refer to the merge_attributes argument in riskscape function info layer_intersection for more info.

Cheers,
Tim

thanks Tim.
For posterity the pipeline ended up being

input(relation: 'Roads_geopackage', name: 'exposure') as exposures_input
 -> select({*})
 -> select({orig_geom: exposure.geom, exposure: layer_intersection(exposure, bookmark('Stop_Banks_merged'), {stb_height: 'stb_height'}, true)})
 -> unnest(exposure, 'segmentID') 
 -> select({{exposure.*, segmentID}})
 -> save('exposure-geoprocessed', format: 'geopackage')

where stb_height was the value I wanted appended to the clipped layer. After clipping the road segments that fell under the Stop_Banks_merged polygon get an integer and the segements that fell outside the Stop_Banks_merged polygon get NULL