I have a postGIS table:
id value geometry
0 10 'g_0_10'
0 20 'g_0_20'
1 10 'g_1_10'
1 20 'g_1_20'
2 10 'g_2_10'
2 20 'g_2_20'
...
Now I have a web application where I want the user to see the intersection of the above geometries for any list of id, grouped by value.
For example, the user wants to see the intersection of geometries for the id list = [x,y,z].
So I want a result that looks like this:
value geoemtry
10 st_intersection(g_x_10, g_y_10, g_z_10)
20 st_intersection(g_x_20, g_y_20, g_z_20)
Can you write such a query if you don't know in advance the size of the list?
More generaly when trying to build dynamic sql queries from Python, do you have to concatenate strings like :
request = "select * from t where id=" + id + ";"
Or is there a cleaner way ?