1.0 - 8.00 - PointInPolygon Example 3: Passenger Coordinates as Separate Columns - 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)

The x and y coordinates of the passenger locations are in columns x and y, respectively.

Input

source_passenger1
customer_id x y customer_name
1 30 10 Jeff
1 300 10 John
1 300 20 Maria
1 400 20 Macy

SQL Call

SELECT * FROM PointInPolygon (
  ON source_passenger1 AS source PARTITION BY ANY
  ON reference_terminal AS reference DIMENSION
  USING
  SourceLocationColumn ('x', 'y')
  ReferenceLocationColumn ('reference_location_polygon')
  ReferenceNameColumns ('terminal_name')
  OutputAll ('false')
  Accumulate ('customer_id', 'customer_name')
) AS dt ORDER BY x, y;

Output

x y ref_reference_location_polygon
30 10 POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0))
300 10 POLYGON ((200 0, 400 0, 400 200, 200 200, 200 0))
300 20 POLYGON ((200 0, 400 0, 400 200, 200 200, 200 0))
Columns 4-7
ref_terminal_name pip_flag customer_id customer_name
Terminal A 1 1 Jeff
Terminal B 1 2 John
Terminal B 1 3 Maria