ArcGIS Server Banner

ST_GeomFromText

ST_GeomFromText

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback

NOTE: Spatial type for Oracle only; for spatial type for PostgreSQL, use ST_Geometry.

Definition

ST_GeomFromText takes a well-known text representation and a spatial reference ID and returns a geometry object.

Syntax

sde.st_geomfromtext (wkt clob, srid integer)

Return type

ST_Geometry

Example

The geometry_test table contains the integer gid column, which uniquely identifies each row, and the g1 column, which stores the geometry.

CREATE TABLE geometry_test (gid smallint unique, g1 sde.st_geometry);

The INSERT statements insert the data into the gid and g1 columns of the geometry_test table. The ST_GeomFromText function converts the text representation of each geometry into its corresponding instantiable subclass. The SELECT statement at the end is done to ensure data was inserted into the g1 column.

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

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

INSERT INTO geometry_test VALUES (
3,
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 geometry_test VALUES (
4,
sde.st_geomfromtext('multipoint (10.02 20.01, 10.32 23.98, 11.92 25.64)', 0)
);

INSERT INTO geometry_test VALUES (
5,
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 geometry_test VALUES (
6,
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)
);

SELECT sde.st_astext(g1)
FROM geometry_test;

See Also

  • An overview of SQL functions used with ST_Geometry types