PointInPolygon Example 3: Passenger Coordinates as Separate Columns - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

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