ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

ST_Relate

  • Definition
  • Syntax
  • Return type
  • Example

Definition

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

Syntax

Oracle and PostgreSQL

sde.st_relate (geometry1 sde.st_geometry, geometry2 sde.st_geometry, patternMatrix string)

SQLite

st_relate (geometry1 geometryblob, geometry2 geometryblob, 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 (T*F**FFF*) will tell you if any two geometries are equal.

In this example, a table, relate_test, is created with three spatial columns, and point features are inserted into each one. The ST_Relate function is used in the SELECT statement to test if the points are equal. Note that if you know you want to determine if geometries are equal, it is recommended that you use the ST_Equals function instead.

Oracle

CREATE TABLE relate_test (
 g1 sde.st_geometry,
 g2 sde.st_geometry,
 g3 sde.st_geometry
);
INSERT INTO relate_test (g1, g2, g3) VALUES (
 sde.st_geometry ('point (10.02 20.01)', 4326),
 sde.st_geometry ('point (10.02 20.01)', 4326),
 sde.st_geometry ('point (30.01 20.01)', 4326)
);
SELECT sde.st_relate (g1, g2, 'T*F**FFF*') g1_equals_g2, 
 sde.st_relate (g1, g3, 'T*F**FFF*') g1_equals_g3, 
 sde.st_relate (g2, g3, 'T*F**FFF*') g2_equals_g3 
 FROM RELATE_TEST;
 
g1_equals_g2     g1_equals_g3      g2_equals_g3

1                0                 0

PostgreSQL

CREATE TABLE relate_test (
 g1 sde.st_geometry,
 g2 sde.st_geometry,
 g3 sde.st_geometry
);
INSERT INTO relate_test (g1, g2, g3) VALUES (
 sde.st_geometry ('point (10.02 20.01)', 4326),
 sde.st_geometry ('point (10.02 20.01)', 4326),
 sde.st_geometry ('point (30.01 20.01)', 4326)
);
SELECT st_relate (g1, g2, 'T*F**FFF*') AS "g1=g2", 
 st_relate (g1, g3, 'T*F**FFF*') AS "g1=g3",
 st_relate (g2, g3, 'T*F**FFF*') AS "g2=g3" 
 FROM relate_test;
 
g1=g2     g1=g3     g2=g3

t          f         f

SQLite

CREATE TABLE relate_test (id integer primary key autoincrement not null);

SELECT AddGeometryColumn(
 NULL,
 'relate_test',
 'g1',
 4326,
 'point',
 'xy',
 'null'
);

CREATE TABLE relate_test2 (id integer primary key autoincrement not null);

SELECT AddGeometryColumn(
 NULL,
 'relate_test2',
 'g2',
 4326,
 'point',
 'xy',
 'null'
);

CREATE TABLE relate_test3 (id integer primary key autoincrement not null);

SELECT AddGeometryColumn(
 NULL,
 'relate_test3',
 'g3',
 4326,
 'point',
 'xy',
 'null'
);
INSERT INTO relate_test (g1) VALUES (
 st_geometry ('point (10.02 20.01)', 4326)
);

INSERT INTO relate_test2 (g2) VALUES (
 st_geometry ('point (10.02 20.01)', 4326)
);

INSERT INTO relate_test3 (g3) VALUES (
 st_geometry ('point (30.01 20.01)', 4326)
);
SELECT st_relate (relate_test.g1, relate_test2.g2, 'T*F**FFF*') AS "g1=g2", 
 st_relate (relate_test.g1, relate_test3.g3, 'T*F**FFF*') AS "g1=g3",
 st_relate (relate_test2.g2, relate_test3.g3, 'T*F**FFF*') AS "g2=g3" 
 FROM relate_test, relate_test2, relate_test3;
 
g1=g2     g1=g3     g2=g3

1          0         0

Related topics

  • Load the SQLite ST_Geometry library

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal