1

I've been given an array of center points(longitude and latitude) and corresponding radius, and try to find all points in these circles.

I know how to find points in the specified circle (the center is (CPLng, CPLat), and radius is 3000m), using the below SQL.

SELECT l.*, ST_Distance(workplace_geom, ref_geom) as distance  
FROM   locations AS l
CROSS JOIN (SELECT ST_MakePoint(CPLng, CPLat)::geography AS ref_geom) AS r 
WHERE  ST_DWithin(workplace_geom, ref_geom, 3000)

In order to get all point in series of circles, should I just union every set of points?

2
  • 1
    There are a number of ways to do this, and the complexity and performance will vary according to the number of features in the two layers, and their distances apart. Without these, the question is incomplete.
    – Vince
    Nov 18 at 4:23
  • If it is fast enough what you have, you could just put this piece of logic up top into a plpgsql for loop which iterates over your circle centroids. Nov 18 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.