- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这两个查询有什么区别:
select a.gid, sum(length(b.the_geom))
from polygons as a
, roads as b
where st_intersects(a.the_geom,b.the_geom)
group by a.gid ;
select a.gid, sum(length(b.the_geom))
from polygons as a
, roads as b
where st_overlaps(a.the_geom,b.the_geom)
group by a.gid ;
第一个查询给出正确的输出,而第二个查询根本没有检索到任何行。与多边形相交的道路也与它重叠,对吗?
最佳答案
来自PostGIS的文档
http://postgis.net/docs/ST_Intersects.html
If a geometry or geography shares any portion of space then they intersect. Overlaps, Touches, Within all imply spatial intersection. If any of the aforementioned returns true, then the geometries also spatially intersect.
http://postgis.net/docs/ST_Overlaps.html
Returns TRUE if the Geometries "spatially overlap". By that we mean they intersect, but one does not completely contain another.
区别在于:如果两个几何图形重叠 100%,则它们不再重叠。
这是一个 POSTGIS 示例:
SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Intersects(a, b) As a_intersects_b, ST_Contains(b, a) As b_contains_a
FROM (SELECT
ST_Polygon(ST_GeomFromText('LINESTRING(1 1,3 1,3 3,1 1)'), 4326) As a,
ST_Polygon(ST_GeomFromText('LINESTRING(1 1,3 1,3 3,1 1)'), 4326) As b)
As foo;
-- INTERSECT is TRUE, OVERLAP is FALSE because B equals A
SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Intersects(a, b) As a_intersects_b, ST_Contains(b, a) As b_contains_a
FROM (SELECT
ST_Polygon(ST_GeomFromText('LINESTRING(1 1,3 1,3 3,1 1)'), 4326) As a,
ST_Polygon(ST_GeomFromText('LINESTRING(1 1,4 1,4 4,1 1)'), 4326) As b)
As foo;
-- INTERSECT is TRUE, OVERLAP is FALSE because B contains A
SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Intersects(a, b) As a_intersects_b, ST_Contains(b, a) As b_contains_a
FROM (SELECT
ST_Polygon(ST_GeomFromText('LINESTRING(0 0,2 0,2 2,0 0)'), 4326) As a,
ST_Polygon(ST_GeomFromText('LINESTRING(1 1,3 1,3 3,1 1)'), 4326) As b)
As foo;
-- INTERSECT is TRUE, OVERLAP is TRUE because not all of A intersects B and not all of B intersects A
关于sql - st_intersects 与 st_overlaps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10480320/
这两个查询有什么区别: select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_i
R 包 sf 在“几何二元谓词”标题下有一组令人惊叹的函数,详细描述了 here . 如链接中所述,如果仅提供一个 sf 对象,则这些函数将递归地应用于同一数据集中的所有几何图形(参见下面的示例) p
我有以下查询:- SELECT ST_Overlaps(a,b) AS a_overlap_b FROM (SELECT ST_GeomFromText ('LINESTRING(-1
我是一名优秀的程序员,十分优秀!