I am trying to create a virtual layer in QGIS that is the intersection of two polygon layers, "Cowardin" and "Wetlands". Both layers are in the map canvas in the same projection (EPSG:6597). I entered the query in the virtual layers dialog:

SELECT Cowardin.*
FROM Cowardin, Wetlands
WHERE st_intersection(Cowardin.geometry, Wetlands.geometry)

And it returns no errors, but when I add the layer to my project it adds a blank layer. What am I doing wrong?

I also tried using the Query Builder in DB manager and got the same query with quotes around layer names, but this was also blank.

  • 2
    I suspect that you want intersects not intersection
    – Ian Turton
    Nov 22, 2023 at 20:23
  • @IanTurton The query works with intersects, but does not clip the boundaries. My "Cowardin" layer covers the area, and I'm trying to just show the portion within the boundaries of the "Wetland" polygons. Nov 22, 2023 at 20:49

1 Answer 1


To get only the intersections, you would have to select the intersection where geometries intersect...

SELECT st_intersection(Cowardin.geometry, Wetlands.geometry) as geometry, 
       Cowardin.id as cid, Wetlands.id as wid
FROM Cowardin, Wetlands
WHERE st_intersects(Cowardin.geometry, Wetlands.geometry)
  • 1
    This would be better if it included a JOIN instead of the 80's style table list.
    – Vince
    Nov 23, 2023 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.