I have a set of LineStrings (streets) and a set of rectangles (atlas pages extents) that could overlap each-other.

And now I want to create a legend for an atlas like

street1, pages: 1,2
street2, pages: 2,3


page1, streets: 1,2,3,5
page2, streets: 2,4,5,6

Page numbers are rectangles' attribute. So I need to spatially join attributes, but relations between streets and pages are many-to-many and QGIS Spatial attributes join allows me only two options: write first occurrence or aggregate over attributes values.

In other words, I want to get the analog of Postgis spatial join like below and write it out (in .csv or other format):

select page.number, street.number, street.name 
   street, page
   ST_INTERSECTS(street.geom, page.geom)

I could run a python script that will iterate over pages, take streets, and write cross joined attributes into a .csv file. But maybe somebody already done this before and has published a solution?


1 Answer 1


I've made a script for this task https://github.com/kiselev-dv/QGIS-Processing/blob/attributes_crossjoin/scripts/spatial_cross_join_attributes.py

Your Answer

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

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