I am trying to learn the usage of Virtual Layers in QGIS but I can't find a solution for a problem that seems very simple.
I have two polygon layers and I want to have the difference.
And this is what I want to get:
How should my query look like to achieve the desired output?
Best Answer
Another solution is to use the
ST_Union()
inside of the query (it was also mentioned in@geozelot's comment), because features from a "cut" layer need to become one geometry (of type
MULTIPOLYGON
). This idea was taken from this thread : More on cutting polygons with polygons, in PostGIS.Let's assume there are two polygon layers called 'grid_test' (green) with nine features and 'grid_test2' (orange) with five features in it, see image below.
So, your query may look like this:
or like this:
and then get the final output
References: