I have two overlapping polygon vector layers.
I want to combine these two layers into one vector layer, but I don't want to keep overlaying parts - the blue layer is of higher importance (weight), so I want to keep only blue features and if there is no blue feature, than keep the red polygon (or said in other words: fill the empty space in blue layer into the boundary of red polygon - the red layer doesn't hold important information, I use it only to know the boundary box to fill).
I know how to do it in multiple steps: use Difference tool (to clip out the blue parts from red polygon) and then Union to combine both layers, but is there please any way how to do it in only one step?
I want to implement it into Python (PyQGIS) script and I don't want to create unnecessary files that take up space and increase computing time.
processing.run("native:red", {'INPUT':blue,'OVERLAY':grid,'OUTPUT':difference})
processing.run("native:union", {'INPUT':difference,'OVERLAY':blue,'OVERLAY_FIELDS_PREFIX':'','OUTPUT':combined_layer})