ArcGIS Server Banner

ST_GeometryType

ST_GeometryType

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

Definition

ST_GeometryType takes an ST_Geometry object and returns its geometry type as a string.

Syntax

Oracle

sde.st_geometrytype (g1 sde.st_geometry)

PostgreSQL

st_geometrytype (g1 st_geometry)

Return type

Varchar(32) containing one of the following

Example

The geometrytype_test table contains the g1 geometry column.

The INSERT statements insert each geometry subclass into the g1 column.

Oracle

CREATE TABLE geometrytype_test (g1 sde.st_geometry);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('point (10.02 20.01)', 0)
);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)', 0)
);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('polygon ((10.02 20.01, 11.92 35.64, 25.02 34.15,
19.15 33.94, 10.02 20.01))', 0)
);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('multipoint (10.02 20.01, 10.32 23.98, 11.92 25.64)', 0)
);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('multilinestring ((10.02 20.01, 10.32 23.98,
11.92 25.64), (9.55 23.75, 15.36 30.11))', 0)
);

INSERT INTO geometrytype_test VALUES (
sde.st_geomfromtext ('multipolygon (((10.02 20.01, 11.92 35.64, 25.02 34.15,
19.15 33.94, 10.02 20.01)), ((51.71 21.73, 73.36 27.04, 71.52 32.87, 52.43 31.90,51.71 21.73)))', 0)
);

PostgreSQL

CREATE TABLE geometrytype_test (g1 st_geometry);

INSERT INTO geometrytype_test VALUES (
st_geometry ('point (10.02 20.01)', 0)
);

INSERT INTO geometrytype_test VALUES (
st_geometry ('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)', 0)
);

INSERT INTO geometrytype_test VALUES (
st_geometry ('polygon ((10.02 20.01, 11.92 35.64, 25.02 34.15,
19.15 33.94, 10.02 20.01))', 0)
);

INSERT INTO geometrytype_test VALUES (
st_geometry ('multipoint (10.02 20.01, 10.32 23.98, 11.92 25.64)', 0)
);

INSERT INTO geometrytype_test VALUES (
st_geometry ('multilinestring ((10.02 20.01, 10.32 23.98,
11.92 25.64), (9.55 23.75, 15.36 30.11))', 0)
);

INSERT INTO geometrytype_test VALUES (
st_geometry ('multipolygon (((10.02 20.01, 11.92 35.64, 25.02 34.15,
19.15 33.94, 10.02 20.01)), ((51.71 21.73, 73.36 27.04, 71.52 32.87, 
52.43 31.90,51.71 21.73)))', 0)
);

The query lists the geometry type of each subclass stored in the g1 geometry column.

Oracle

SELECT UPPER (sde.st_geometrytype (g1)) Geometry_type
FROM geometrytype_test;

Geometry_type

ST_POINT
ST_LINESTRING
ST_POLYGON
ST_MULTIPOINT
ST_MULTILINESTRING
ST_MULTIPOLYGON

PostgreSQL

SELECT (st_geometrytype (g1)) AS Geometry_type
FROM geometrytype_test;

Geometry_type

ST_POINT
ST_LINESTRING
ST_POLYGON
ST_MULTIPOINT
ST_MULTILINESTRING
ST_MULTIPOLYGON

See Also

  • An overview of SQL functions used with ST_Geometry types