The trip data contains the origin-destination of each trip, and both origin and destination are stored as geometries. How could I retrieve the origin and destination polygons that the points are located?
The following code works fine to find the polygon which the origin is located. I need to determine the destination_polygon as well.
SELECT p.id as origin_polygon FROM trips t, polygons p WHERE ST_Contains(p.geom, t.origin)