ArcGIS Server Banner

ST_Relate

ST_Relate

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

Definition

ST_Relate compares two geometries and returns 1 (Oracle) or t (PostgreSQL) if the geometries meet the conditions specified by the DE-9IM pattern matrix string; otherwise, 0 (Oracle) or f (PostgreSQL) is returned.

Syntax

Oracle

sde.st_relate (g1 st_geometry, g2 st_geometry, patternMatrix String)

PostgreSQL

st_relate (g1 st_geometry, g2 st_geometry, patternMatrix string)

Return type

Boolean

Example

A DE-9IM pattern matrix is a device for comparing geometries. There are several types of such matrices. For example, the equals pattern matrix will tell you if any two geometries are equal.

The table RELATE_TEST is created with the following CREATE TABLE statement.

Oracle

CREATE TABLE RELATE_TEST (g1 sde.st_geometry, g2 sde.st_geometry, g3 sde.st_geometry);

PostgreSQL

CREATE TABLE relate_test (g1 st_geometry, g2 st_geometry, g3 st_geometry);

The following INSERT statements insert a sample subclass into the RELATE_TEST table.

Oracle

INSERT INTO RELATE_TEST VALUES (
sde.st_pointfromtext ('point (10.02 20.01)', 0),
sde.st_pointfromtext ('point (10.02 20.01)', 0),
sde.st_pointfromtext ('point (30.01 20.01)', 0)
);

PostgreSQL

INSERT INTO RELATE_TEST VALUES (
st_point ('point (10.02 20.01)', 0),
st_point ('point (10.02 20.01)', 0),
st_point ('point (30.01 20.01)', 0)
);

The following SELECT statement and the corresponding result set list the subclass name stored in the GEOTYPE column with the dimension of that geotype.

Oracle

SELECT sde.st_relate (g1, g2, 'T*F**FFF*') equals, sde.st_relate (g1, g3, 'T*F**FFF*') not_equals 
FROM relate_test;

equals     not_equals 

1          0

PostgreSQL

SELECT st_relate (g1, g2, 'T*F**FFF*') AS equals, st_relate (g1, g3, 'T*F**FFF*') AS not_equals 
FROM relate_test;

equals     not_equals 

t          f

See Also

  • An overview of SQL functions used with ST_Geometry types
  • Spatial relationships