Returns the geometry of one component member of a composite geometry type (ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon). The element to be returned is specified by position with the collection.
Argument … |
Specifies … |
aposition |
an INTEGER value representing the position in the collection of the geometry to be returned. The position of the first element in the collection is number 1. |
Returns an ST_Geometry value.
ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, and ST_MultiPolygon
CREATE TABLE sample_shapes (skey INTEGER, shape ST_Geometry);
INSERT INTO sample_shapes VALUES (1001,'MultiPoint((10 20 30),(40 50 60),(70 80 90))');
INSERT INTO sample_shapes VALUES (1002,
'MultiLineString((10 20 30,10 20 50,10 20 70,10 20 90),(5 5 5,10 10 10,15 15 15,20 20 20,25 25 25,30 30 30))');
INSERT INTO sample_shapes VALUES
(1003,'MultiPolygon(((0 0 0,0 20 20,20 20 20,20 0 20,0 0 0)),((50 50 50,50 90 90,90 90 90,90 50 90,50 50 50)))');
INSERT INTO sample_shapes VALUES
(1004,'Geometrycollection(Point(10 20 30),Linestring(1 2 3,4 5 6,7 8 9), Polygon((0 0 0,0 40 40,40 40 40,40 0 40,0 0 0)))');
SELECT shape.ST_GeometryN(2)
FROM sample_shapes
WHERE skey = 1001;