Skip to main content
deleted 123 characters in body
Source Link
Paul Ramsey
  • 20k
  • 2
  • 49
  • 58
create table boundaries as
    with collection as (
      select st_collect(st_exteriorring(geom)) as geom from circles
    )
    select st_union(geom, st_geometrynst_exteriorring(geom, 1)) as geom from collection;circles;
create table boundaries as
    with collection as (
      select st_collect(st_exteriorring(geom)) as geom from circles
    )
    select st_union(geom, st_geometryn(geom, 1)) as geom from collection;
create table boundaries as
    select st_union(st_exteriorring(geom)) as geom from circles;
edited body
Source Link
Paul Ramsey
  • 20k
  • 2
  • 49
  • 58

Now butterbuffer the points into circles so we get some overlap.

Now butter the points into circles so we get some overlap.

Now buffer the points into circles so we get some overlap.

added 113 characters in body
Source Link
Paul Ramsey
  • 20k
  • 2
  • 49
  • 58

Now, add a place for the polygon count and fill it up by joining the centroids of the small cut-up polygons to the original circles, and summarizing for each small piece. For larger data sets an index on the circles table at least will be required to make things not impossibly slow.

create index circles_gix on circles using gist (geom);

alter table polys add column count integer;integer default 0;

update polys set count = p.count 
from (
    select count(*) as count, 
           p.id as id 
    from polys p 
    join circles c 
    on st_contains(c.geom, st_pointonsurface(p.geom)) 
    group by p.id
) as p
where p.id = polys.id;

Now, add a place for the polygon count and fill it up by joining the centroids of the small cut-up polygons to the original circles, and summarizing for each small piece.

alter table polys add column count integer;

update polys set count = p.count 
from (
    select count(*) as count, 
           p.id as id 
    from polys p 
    join circles c 
    on st_contains(c.geom, st_pointonsurface(p.geom)) 
    group by p.id
) as p
where p.id = polys.id;

Now, add a place for the polygon count and fill it up by joining the centroids of the small cut-up polygons to the original circles, and summarizing for each small piece. For larger data sets an index on the circles table at least will be required to make things not impossibly slow.

create index circles_gix on circles using gist (geom);

alter table polys add column count integer default 0;

update polys set count = p.count 
from (
    select count(*) as count, 
           p.id as id 
    from polys p 
    join circles c 
    on st_contains(c.geom, st_pointonsurface(p.geom)) 
    group by p.id
) as p
where p.id = polys.id;
Source Link
Paul Ramsey
  • 20k
  • 2
  • 49
  • 58
Loading