1.0 - 8.00 - GeometryOverlay Example 1: Intersection - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

Input

  • source: source_gatetype, which contains the geometrical coordinates of US and international gates in three airport terminals (A, B, and C)
  • reference: ref_terminal, which contains the terminal coordinates in WKT syntax
source: source_gatetype
id boundary_coordinates boundary_name boundary_attributes
1 POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10)) US Gates US
2 POLYGON ((50 50, 50 150, 150 150, 150 50,50 50)) International Gates International
reference: ref_terminal
id boundary_coordinates boundary_name boundary_attributes
1 POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0)) Terminal A A
2 POLYGON ((100 0, 200 0, 200 100, 100 100, 100 0)) Terminal B B
3 POLYGON ((0 100, 100 100, 100 200, 0 200, 0 100)) Terminal C C

SQL Call

SELECT * FROM GeometryOverlay (
  ON source_gatetype AS source PARTITION BY ANY
  ON ref_terminal AS reference DIMENSION
  USING
  SourceLocationColumn ('boundary_coordinates')
  ReferenceLocationColumn ('boundary_coordinates')
  ReferenceNameColumns ('boundary_name')
  BoundaryOperator ('intersection')
  OutputAll ('false')
  Accumulate ('boundary_attributes')
) AS dt ORDER BY 2, 1;

Output

The output shows that all domestic gates are within Terminal A. International gates are spread over all three terminals.

overlay_boundary ref_boundary_name overlay_flag boundary_attributes
POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10)) Terminal A 1 In the US
POLYGON ((50 50, 50 100, 100 100, 100 50, 50 50)) Terminal A 1 International
POLYGON ((150 100, 150 50, 100 50, 100 100, 150 100)) Terminal B 1 International
POLYGON ((50 100, 50 150, 100 150, 100 100, 50 100)) Terminal C 1 International