se_dissolve.sql 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- This example demonstrates how to use SE_Dissolve to combine several
  2. -- geometries into a single geometry by aggregation.
  3. --
  4. -- The source geometries must all be of the same dimension; you cannot
  5. -- combine points with linestrings, etc.
  6. -- Example 1: combining points
  7. CREATE TABLE well_locations (id integer,
  8. locn ST_Point);
  9. INSERT INTO well_locations VALUES(1, "1000 point (34.326 43.452)");
  10. INSERT INTO well_locations VALUES(2, "1000 point (18.143 56.987)");
  11. INSERT INTO well_locations VALUES(3, "1000 point (76.722 87.732)");
  12. SELECT SE_Dissolve(locn) FROM well_locations;
  13. -- Example 2: combining polygons
  14. CREATE TABLE honeycomb (cell_id int,
  15. cell ST_Polygon);
  16. INSERT INTO honeycomb
  17. VALUES (1, '0 polygon((5 10,7 7,10 7,12 10,10 13,7 13,5 10))');
  18. INSERT INTO honeycomb
  19. VALUES (2, '0 polygon((12 4,15 4,17 7,15 10,12 10,10 7,12 4))');
  20. INSERT INTO honeycomb
  21. VALUES (3, '0 polygon((17 7,20 7,22 10,20 13,17 13,15 10,17 7))');
  22. INSERT INTO honeycomb
  23. VALUES (4, '0 polygon((15 10,17 13,15 16,12 16,10 13,12 10,15 10))');
  24. select SE_Dissolve(cell) from honeycomb;