ArcGIS Server Banner

ST_GeometryN

ST_GeometryN

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.

Definition

ST_GeometryN takes a collection and an integer index and returns the nth ST_Geometry object in the collection.

Syntax

Oracle

sde.st_geometryn (mpt1 sde.st_multipoint, index integer)
sde.st_geometryn (mln1 sde.st_multilinestring, index integer)
sde.st_geometryn (mpl1 sde.st_multipolygon, index integer)

PostgreSQL

st_geometryn (mpt1 st_multipoint, index integer)
st_geometryn (mln1 st_multilinestring, index integer)
st_geometryn (mpl1 st_multipolygon, index integer)

Return type

ST_Geometry

Example

In this example, a multipolygon is created. Then ST_GeometryN is used to list the second element of the multipolygon.

Oracle

CREATE TABLE districts (dist_id integer, shape sde.st_multipolygon);

INSERT INTO districts (dist_id, shape) VALUES (
1,
sde.st_multipolygon ('multipolygon (((-1 -1, -1 11, 11 11, 11 -1, -1 -1),
(19 -1, 19 11, 29 9, 31 -1, 19 -1), (39 -1, 39 11, 51 11, 51 -1, 39 -1)))', 0)
);

SELECT sde.st_astext (sde.st_geometryn (shape, 2)) Second_Element
FROM districts;

Second_Element

POLYGON  ((-1.00000000 -1.00000000, 11.00000000 -1.00000000, 11.0000000 0 11.000

PostgreSQL

CREATE TABLE districts (dist_id integer, shape st_geometry);

INSERT INTO districts (dist_id, shape) VALUES (
1,
st_multipolygon ('multipolygon (((-1 -1, -1 11, 11 11, 11 -1, -1 -1),
(19 -1, 19 11, 29 9, 31 -1, 19 -1), (39 -1, 39 11, 51 11, 51 -1, 39 -1)))', 0)
);

SELECT st_astext (st_geometryn (shape, 2)) AS Second_Element
FROM districts;

Second_Element

POLYGON  ((39 -1, 51 -1, 51 11, 39 11, 39 -1))

See Also

  • An overview of SQL functions used with ST_Geometry types