如何使用ST_Intersection获取多个几何体?

huangapple go评论52阅读模式
英文:

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:

如何使用ST_Intersection获取多个几何体?.

Although I am expecting a result like this:

如何使用ST_Intersection获取多个几何体?

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:

如何使用ST_Intersection获取多个几何体?.

Although I am expecting a result like this:

如何使用ST_Intersection获取多个几何体?

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)

huangapple
  • 本文由 发表于 2023年6月8日 14:27:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76429129.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定