英文:
How to get several geometries with ST_Intersection?
问题
I have a layer of polygons (lulc) and I have a layer of points (sensors).
I would like to have all the polygons inside buffer zones around the points as I can do in QGIS
So I have tried this request:
SELECT ST_Intersection(lulc.geom, ST_Buffer(sensors.geom, 200, 'quad_segs=50'))
FROM sensors
JOIN lulc ON ST_Intersects(sensors.geom, lulc.geom)
But the result was this:
.
Although I am expecting a result like this:
I understand that ST_Intersection
returns only one geometry, but what should I do to have all the polygons inside the buffer zones? (sub-question: how does ST_Intersection
choose the geometry that will be its result?)
英文:
I have a layer of polygons (lulc) and I have a layer of points (sensors).
I would like to have all the polygons inside buffer zones around the points as I can do in QGIS
So I have tried this request:
SELECT ST_Intersection(lulc.geom,ST_Buffer(sensors.geom,200,'quad_segs=50'))
FROM sensors
JOIN lulc ON ST_Intersects (sensors.geom,lulc.geom)
But the result was this:
.
Although I am expecting a result like this:
I understand that ST_Intersection
returns only one geometry but what should I do for having all the polygons inside the buffer zones?
(sub-questions how does ST_Intersection
choose the geometry that will be its result?)
答案1
得分: 0
ST_Intersection
会返回所有的交集,它不会过滤任何几何图形。
在你的查询中,你只选择与传感器点相交的多边形,然后使用这些多边形计算与传感器点缓冲区的交集。
相反,你将希望连接传感器点附近的多边形,然后计算交集:
SELECT ST_Intersection(lulc.geom, ST_Buffer(sensors.geom, 200, 'quad_segs=50'))
FROM sensors
JOIN lulc ON ST_DWITHIN(sensors.geom, lulc.geom, 200)
英文:
ST_Intersection
will return every intersections, it doesn't filter out any geometry.
In your query, you are selecting only the polygons that intersect the sensor point, and then, using theses polygons, you compute the intersection with the buffer of the sensor point.
Instead, you will want to join the polygons that are in the vicinity of the sensor points, and then compute the intersections:
SELECT ST_Intersection(lulc.geom,ST_Buffer(sensors.geom,200,'quad_segs=50'))
FROM sensors
JOIN lulc ON ST_DWITHIN(sensors.geom,lulc.geom,200)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论