1

I have a table of boundaries as polygons and another table of peaks as points. I want to find the points that are within the polygons and the polygons are extended with a buffer. What would be the fastest way to do that?

At the moment I am trying to work with ST_Within which gives me good results, but adding ST_Buffer does not seem to work:

SELECT p.name, p.elev, a.name FROM eu_peaks p, eu_admin_valid a where
    ST_Within(p.geom, ST_Buffer(a.the_geom, 0.02))
    order by a.name;

Is this a good approach? What should I change?

0

1 Answer 1

4

Buffering is an expensive process. The preferred method is st_DWithin. Your query could be:

SELECT
  p.name, p.elev, a.name
FROM
  eu_peaks p, eu_admin_valid a
WHERE
  ST_DWithin(p.geom, a.the_geom, 0.02)
ORDER BY
  a.name;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.