# Finding outermost border of set of geomertries (circles) using PostGIS?

I have a (large) set of geometries (circles) that overlap.! I would like to find the nearest location outside of this group from my current location. In this example my location is the black dot. In my scenario I would like to get out of this group of circles and find the edge / border of this group, do I can draw a point on (or just outside of it), this would be the red dot. Is there any way to achieve this using postgis without first having to draw an infinite amount of points to test against?

• Is this an operation that you need to repeat numerous times? Because one way of doing this would be to dissolve the circles into a geometry and check the distance of the vertices to the point of interest. However, if you need to repeat this operation millions of times, the efficiency of the dissolve would make this approach less feasible. – WhiteboxDev Dec 2 '14 at 13:06
• I don't need to repeat it per se, it's just that the users position (black dot) will be different each time. – Richard Vijgen Dec 2 '14 at 13:14
• Also, if i would check the individual vertices, how would I know if they are "border" vertices or vertices that are overlapping with other circles? – Richard Vijgen Dec 2 '14 at 13:15
• That's where the dissolve operation comes in. When you dissolve the circles, you'll end up with a geometry that is only the outer border of the group of circles. You can then check the distance to each vertex in that geometry to your POI, as an approximate. It should scale okay for thousands or millions of points. – WhiteboxDev Dec 2 '14 at 13:17
• For all POI that are not located within the convex lobe of an outer circle (border), the nearest point will always be one of the intersection points between two outer circles, and these vertices will certainly be part of the dissolve geometry. So the method I describe above will actually work quite well, and for efficiency you should check the distance to these key intersection points first. – WhiteboxDev Dec 2 '14 at 13:21

• `Select st_closestpoint(st_boundary(st_union(geom)), pt) from table_of_circles` I think you mean :D. – John Powell Dec 2 '14 at 15:27