You need to test the intersection on itself using a left join
. Then you can do a group by
using the geometry and finally set a filter only on those that have a count(1)
equal to one. According to your data you need to replace the name of the initial points table in the with
clause and you need to rename all occurrences of the geometry column.
with sub as(
select
*,
st_buffer(geometry, 15000) as geometry
from
points
)
select
*
from sub a
left join sub b
on st_intersects(a.geometry, b.geometry)
group by a.geometry
having count(1) = 1
Update
If you have more than the geometry column this will work (we need to rejoin with the first sub-query). But maybe there is a faster solution.
with sub as(
select
st_buffer(geometry, 15000) as geometry
from
points
)
select
*
from (
select
*
from (
select
a.geometry,
count(1) as count
from sub a
left join sub b
on st_intersects(a.geometry, b.geometry)
group by a.geometry
) sub2
where sub2.count = 1
) sub3
left join sub
on st_equals(sub.geometry, sub3.geometry)

ST_DWithin
.