Skip to content

Instantly share code, notes, and snippets.

@sylvia43
Last active August 29, 2015 14:05
Show Gist options
  • Save sylvia43/1bf7cd561e0c08ba1839 to your computer and use it in GitHub Desktop.
Save sylvia43/1bf7cd561e0c08ba1839 to your computer and use it in GitHub Desktop.

1. Get the outlines of the circles (ran very fast)

create table circle_outlines as 
SELECT distinct ST_ExteriorRing(the_circle) AS the_geom FROM circle_list;
create index idx_geom_circle_outlines  on circle_outlines  using gist (the_geom);
select distinct geometrytype(the_geom) from circle_outlines ; -- LINESTRING

2. Combine the lines

3A. Check out the geom type created, if interested (should be GEOMETRYCOLLECTION)

3B. Polygonize from the merged borders (ST_Dump((ST_Polygonize(the_geom)))

4. Add points inside using ST_PointOnSurface(polygonized_geoms)

5. Calculate num_overlaps


  1. This is a normal ordered list.
  2. This is a normal ordered list.
  3. This is a normal ordered list.
  4. This is a normal ordered list.

https://docs.google.com/document/d/1l1FqBW7bGeOAsn0QoDUjjYEMQ7wK8nupJevG1jI0eMA/edit?usp=sharing&pli=1

@codygray
Copy link

  1. Get the outlines of the circles (ran very fast)
create table circle_outlines as 
SELECT distinct ST_ExteriorRing(the_circle) AS the_geom FROM circle_list;
create index idx_geom_circle_outlines  on circle_outlines  using gist (the_geom);
select distinct geometrytype(the_geom) from circle_outlines ; -- LINESTRING
  1. Combine the lines

3A. Check out the geom type created, if interested (should be GEOMETRYCOLLECTION)

3B. Polygonize from the merged borders (ST_Dump((ST_Polygonize(the_geom)))

  1. Add points inside using ST_PointOnSurface(polygonized_geoms)

  2. Calculate num_overlaps


  1. This is a normal ordered list.
  2. This is a normal ordered list.
  3. This is a normal ordered list.
  4. This is a normal ordered list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment