Spatial Functions (Derive polygon from point)
Problem Description:
I have two fields defined as sdo_geometry, a point and polygon, belonging to two different tables.
I want to establish to which area (polygon) a specific point belongs to and wrote the following SQL to derive that:
select
p.legal_entity_id
, p.city
, p.location point
, c.geometry polygon
, sdo_geom.relate(c.geometry, 'CONTAINS', p.location, 0.05) AS sdo_relate
from
rfiling_legal_entity_point p
, zaf_adm1 c
where p.legal_entity_id in
(
-- Test Cases
'1263',
'1289'
)
and c.name_1 = 'Eastern Cape' -- province / area (polygon);
The problem with this SQL is that I need to compare every point with every polygon, which is not an very effective way of processing all the records.