Skip to content

Instantly share code, notes, and snippets.

@rhysallister
Last active September 16, 2016 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhysallister/bcb4bb07a99d69938fff88f150883bee to your computer and use it in GitHub Desktop.
Save rhysallister/bcb4bb07a99d69938fff88f150883bee to your computer and use it in GitHub Desktop.
blow out duplicate points to a circle
with one as (
select st_x(g),st_y(g), g,count(premises), array_agg(premises) from service.location
where g is not null
group by 1,2,3
having count(premises) > 1
order by 3 desc
)
,qq as
(select *, st_exteriorring(st_buffer(g,3,count::int/3)) gring, unnest(array_agg) from one )
,tt as (
select row_number() over (),*, st_pointn(gring,(row_number() over (partition by st_x,st_y))::int)jj from qq)
--select * from tt
update service.location set g = st_setsrid(jj,3448)
from tt where premises = unnest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment