Las consultas harán el trabajo, pero probablemente puedan optimizarse, por ejemplo, procediendo con un bucle . Actualmente trabajando en esas mejoras
Probado en QGIS 2.18 y QGIS 3.4
Puedo sugerir el uso de un "Virtual Layer"
a través de Layer > Add Layer > Add/Edit Virtual Layer...
Opción 1. Para características en diferentes capas
Supongamos que tenemos las siguientes capas "some_points"
y dos capas de polígonos, "Layer_1"
(dos funciones) y "Layer_2"
(tres características) en consecuencia, véase la imagen siguiente.
Con la siguiente consulta, es posible crear una variable que sea TRUE
o FALSE
.
SELECT poi.*,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "Layer_1" AS l1
WHERE st_intersects(poi.geometry, l1.geometry)
AND l1.id = 1)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Layer1_1,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "Layer_1" AS l1
WHERE st_intersects(poi.geometry, l1.geometry)
AND l1.id = 2)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Layer1_2,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "Layer_2" AS l2
WHERE st_intersects(poi.geometry, l2.geometry)
AND l2.id = 1)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Layer2_1,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "Layer_2" AS l2
WHERE st_intersects(poi.geometry, l2.geometry)
AND l2.id = 2)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Layer2_2,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "Layer_2" AS l2
WHERE st_intersects(poi.geometry, l2.geometry)
AND l2.id = 3)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Layer2_3
FROM "some_points" AS poi
La Capa Virtual de salida con su tabla de Atributos tendrá el siguiente aspecto.
Opción 2. Para los elementos de una capa
Supongamos que tenemos las siguientes capas "some_points"
y "some_polygons"
Ver imagen más abajo.
Con la siguiente consulta, es posible crear una variable que sea TRUE
o FALSE
.
SELECT poi.*,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "some_polygons" AS pol
WHERE st_intersects(poi.geometry, pol.geometry)
AND pol.id = 1)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Polygon1,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "some_polygons" AS pol
WHERE st_intersects(poi.geometry, pol.geometry)
AND pol.id = 2)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Polygon2,
(CASE
WHEN poi.id IN
(SELECT poi.id
FROM "some_points" AS poi, "some_polygons" AS pol
WHERE st_intersects(poi.geometry, pol.geometry)
AND pol.id = 3)
THEN 'TRUE'
ELSE 'FALSE'
END) AS Polygon3
FROM "some_points" AS poi
La Capa Virtual de salida con su tabla de Atributos tendrá el siguiente aspecto.