PointInPolygon Example: Passenger Coordinates in Columns | Teradata Vantage - PointInPolygon Example: Passenger Coordinates in Columns - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.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

  • SourceTable: source_passenger1, which groups parsed location file formats and contains four passengers with known x and y coordinates
  • ReferenceTable: reference_terminal, as in PointInPolygon Example: OutputAll ('true')
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 SourceTable PARTITION BY ANY
  ON reference_terminal AS ReferenceTable 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                    ref_terminal_name pip_flag customer_id customer_name 
 --- -- ------------------------------------------------- ----------------- -------- ----------- ------------- 
  30 10 polygon ((0 0, 100 0, 100 100, 0 100, 0 0))       terminal a               1           1 jeff         
 300 10 polygon ((200 0, 400 0, 400 200, 200 200, 200 0)) terminal b               1           2 john         
 300 20 polygon ((200 0, 400 0, 400 200, 200 200, 200 0)) terminal b               1           3 maria

Download a zip file of all examples and a SQL script file that creates their input tables.