ST_Aggr_Intersection

NoteNote:

Oracle and SQLite only

Definition

ST_Aggr_Intersection returns a single geometry that is a union of the intersection of all input geometries.

Syntax

Oracle

sde.st_aggr_intersection (geometry1 sde.st_geometry)

SQLite

st_aggr_intersection (geometry1 geometryblob)

Return type

Oracle

ST_Geometry

SQLite

Geometryblob

Example

In this example, a biologist is trying to find the intersection of three wildlife habitats.

Oracle

First, create the table that stores the habitats.

CREATE TABLE habitats (
 id integer not null,
 shape sde.st_geometry
);

Next, insert the three polygons to the table.

INSERT INTO habitats (id, shape) VALUES (
 1,
 sde.st_polygon ('polygon ((5 5, 12 5, 12 10, 5 10, 5 5))', 4326)
);

INSERT INTO habitats (id, shape) VALUES (
 2,
 sde.st_polygon ('polygon ((10 8, 14 8, 14 15, 10 15, 10 8))', 4326)
);

INSERT INTO habitats (id, shape) VALUES (
 3,
 sde.st_polygon ('polygon ((6 8, 20 8, 20 20, 6 20, 6 8))', 4326)
);

Finally, select for the intersection of the habitats.

SELECT sde.st_astext(sde.st_aggr_intersection(shape)) AGGR_SHAPES 
 FROM habitats;

AGGR_SHAPES

POLYGON  (( 10.00000000 8.00000000, 12.00000000 8.00000000, 12.00000000 10.00000000, 
10.00000000 10.00000000, 10.00000000 8.00000000))

SQLite

First, create the table that stores the habitats.

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

SELECT AddGeometryColumn(
 NULL,
 'habitats',
 'shape',
 4326,
 'polygon',
 'xy',
 'null'
);

Next, insert the three polygons to the table.

INSERT INTO habitats (shape) VALUES (
 st_polygon ('polygon ((5 5, 12 5, 12 10, 5 10, 5 5))', 4326)
);

INSERT INTO habitats (shape) VALUES (
 st_polygon ('polygon ((10 8, 14 8, 14 15, 10 15, 10 8))', 4326)
);

INSERT INTO habitats (shape) VALUES (
 st_polygon ('polygon ((6 8, 20 8, 20 20, 6 20, 6 8))', 4326)
);

Finally, select the intersection of the habitats.

SELECT st_astext(st_aggr_intersection(shape)) 
  AS "AGGR_SHAPES" 
  FROM habitats;

AGGR_SHAPES

POLYGON  (( 10.00000000 8.00000000, 12.00000000 8.00000000, 12.00000000 10.00000000, 
10.00000000 10.00000000, 10.00000000 8.00000000))

Related Topics

6/19/2015