ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

ST_DWithin

  • 定义
  • 语法
  • 返回类型
  • 示例

注:

仅限 Oracle 和 PostgreSQL

定义

ST_DWithin 将两个几何作为输入,如果几何彼此间距离在指定范围内则返回 true;否则将返回 false。几何的空间参考系统决定指定距离将应用的测量单位。因此,提供给 ST_DWithin 的几何必须使用同样的坐标投影和 SRID。

语法

sde.st_dwithin (st_geometry geometry1, st_geometry geometry2, double_precision distance);

返回类型

布尔型

示例

在下例中,创建了两张表,并向其中插入了要素。接下来,使用 ST_DWithin 函数来确定第一个表中的点与第二个表中面是否相距 100 米以内。

--Create table to store points.
CREATE TABLE dwithin_test_pt (id INT, geom sde.st_geometry);
--Create table to store polygons.
CREATE TABLE dwithin_test_poly (id INT, geom sde.st_geometry);
--Insert features into each table.
INSERT INTO dwithin_test_pt 
 VALUES
 (
  1,
  sde.st_geometry('point (1 2)', 4326)
 )
;
INSERT INTO dwithin_test_pt
 VALUES
 (
  2,
  sde.st_geometry('point (10.02 20.01)', 4326)
 )
;
INSERT INTO dwithin_test_poly
 VALUES
 (
  1,
  sde.st_geometry('polygon ((10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01))', 4326)
 )
;
INSERT INTO dwithin_test_poly
 VALUES
 (
  2,
  sde.st_geometry('polygon ((101.02 200.01, 111.92 350.64, 250.02 340.15, 190.15 330.94, 101.02 200.01))', 4326)
 )
;
然后,使用 ST_DWithin 确定每个表中有哪些要素彼此相距 100 米以内,而哪些不是。将 ST_Distance 函数包含在此语句中,以便显示要素间的实际距离。

--Determine which features in the point table are within 100 meters of the features in the polygon table. SELECT pt.id, poly.id, sde.st_distance(pt.geom, poly.geom) distance_meters, sde.st_dwithin(pt.geom, poly.geom, 100) DWithin
 FROM dwithin_test_pt pt, dwithin_test_poly poly;

在运行 PostgreSQL 中的数据时,SELECT 语句返回以下内容:

id     id     distance_meters        dwithin
1      1      20.1425048094819       t
1      2      221.837689538996       f
2      1      0                      t
2      2      201.69531476958        f

在运行 Oracle 中的数据时,该语句返回以下内容:

ID     ID   DISTANCE_METERS   DWITHIN 1      1         20.1425048         1 1      2          221.83769         0 2      1                  0         1
2      2         201.695315         0

在下例中,ST_DWithin 用来确定彼此相距 300 米以内的各个要素:

--Determine which features in the point table are within 300 meters of the features in the polygon table.
SELECT pt.id, poly.id, sde.st_distance(pt.geom, poly.geom) distance_meters, sde.st_dwithin(pt.geom, poly.geom, 300) DWithin
 FROM dwithin_test_pt pt, dwithin_test_poly poly;

第二个 SELECT 语句在运行 PostgreSQL 中的数据时返回以下内容:

id     id     distance_meters        dwithin
1      1      20.1425048094819       t
1      2      221.837689538996       t
2      1      0                      t
2      2      201.69531476958        t

运行 Oracle 中的数据时,第二个 SELECT 语句返回以下内容:

ID     ID   DISTANCE_METERS    DWITHIN 1      1         20.1425048          1 1      2          221.83769          1 2      1                  0          1
2      2         201.695315          1

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2019 Esri. | 隐私政策 | 法律声明