ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

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

ST_GeomFromCollection

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

注:

仅限 PostgreSQL

定义

ST_GeomFromCollection 返回 st_geometry 行集。每行包含几何和整数。整数表示几何在该行集中的位置。

使用 ST_GeomFromCollection 函数访问多部分几何中的各个几何。当输入几何为集合或多部分几何(例如:ST_MultiLineString、ST_MultiPoint、ST_MultiPolygon)时,ST_GeomFromCollection 将返回每个集合组件的记录,同时路径即表示组件在集合中的位置。

如果对简单几何(例如:ST_Point、ST_LineString、ST_Polygon)使用 ST_GeomFromCollection, 由于仅有一个几何,因此将返回路径为空的单一记录。

语法

sde.st_geomfromcollection (shape sde.st_geometry)

要仅返回几何,请使用 (sde.st_geomfromcollection (shape)).st_geo。

要仅返回几何位置,请使用 (sde.st_geomfromcollection (shape)).path[1]。

返回类型

ST_Geometry 集合

示例

在此示例中,将创建多个要素类 (ghanasharktracks),其中包含具有四部分形状的单一要素。

--Create the feature class.
CREATE TABLE ghanasharktracks (objectid integer, shape sde.st_geometry);
--Insert a multiline with four parts using SRID 4326.
INSERT INTO ghanasharktracks VALUES
 (1,
  sde.st_geometry('MULTILINESTRING Z (( 1 1 0, 1 6 0),(1 3 0, 3 3 0),(3 1 0, 3 3 0), (4 1 0, 4 6 0))',
  4326
  )
 );

要确认字段包含数据,请查询表。在形状字段中直接输入 ST_AsText,将形状坐标视为文本。请注意,返回多线串的文本描述。

--View inserted feature. SELECT gst_orig.objectid, sde.st_astext(gst_orig.shape) shapetext FROM ghanasharktracks gst_orig;
shapetext
-------------------------------
"MULTILINESTRING Z (( 1.00000000 1.00000000 0.00000000, 1.00000000 6.00000000 0.00000000),(1.00000000 3.00000000 0.00000000, 3.00000000 3.00000000 0.00000000),(3.00000000 1.00000000 0.00000000, 3.00000000 3.00000000 0.00000000), (4.00000000 1.00000000 0.00000000, 4.00000000 6.00000000 0.00000000))"

要单独返回每个线串几何,请使用 ST_GeomFromCollection 函数。要将几何视为文本,本示例将 ST_GeomFromCollection 函数与 ST_AsText 函数一起使用。

--Return each linestring in the multilinestring
SELECT sde.st_astext((sde.st_geomfromcollection(gst.shape)).st_geo) shapetext, ((sde.st_geomfromcollection(gst.shape)).path[1]) path FROM ghanasharktracks gst;
shapetext                                                                                     path
-----------------------------------------------------------------------------------------------------------
"LINESTRING Z ( 1.00000000 1.00000000 0.00000000, 1.00000000 6.00000000 0.00000000)"          1
"LINESTRING Z ( 1.00000000 3.00000000 0.00000000, 3.00000000 3.00000000 0.00000000)"          2
"LINESTRING Z ( 3.00000000 1.00000000 0.00000000, 3.00000000 3.00000000 0.00000000)"          3
"LINESTRING Z ( 4.00000000 1.00000000 0.00000000, 4.00000000 6.00000000 0.00000000)"          4

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

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