se_boundingbox.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. -- This example demonstrates how to use the SE_BoundingBox function
  2. -- to obtain the spatial extent of all geometries in a table.
  3. CREATE TABLE buildingfootprints (building_id integer,
  4. lot_id integer,
  5. footprint ST_MultiPolygon);
  6. INSERT INTO buildingfootprints VALUES(
  7. 506, 1010,
  8. ST_MPolyFromText('multipolygon (((7.0 45.0,15.0 45.0,15.0 51.0,18.0 51.0,18.0 54.0,8.0 54.0,8.0 51.0,7.0 51.0,7.0 45.0)))',1000)
  9. );
  10. INSERT INTO buildingfootprints VALUES(
  11. 543, 2930,
  12. ST_MPolyFromText('multipolygon (((26.0 55.0,38.0 55.0,38.0 48.0,34.0 48.0,34.0 50.0,26.0 50.0,26.0 55.0)))',1000)
  13. );
  14. INSERT INTO buildingfootprints VALUES(
  15. 1208, 203,
  16. ST_MPolyFromText('multipolygon (((8.0 39.0,12.0 39.0,12.0 33.0,17.0 33.0,17.0 22.0,8.0 22.0,8.0 39.0)))',1000)
  17. );
  18. INSERT INTO buildingfootprints VALUES(
  19. 178, 5192,
  20. ST_MPolyFromText('multipolygon (((26.0 33.0,38.0 33.0,38.0 24.0,33.0 24.0,33.0 27.0,26.0 27.0,26.0 33.0)))',1000)
  21. );
  22. CREATE INDEX footprint_ix
  23. ON buildingfootprints (footprint ST_Geometry_ops)
  24. USING RTREE;
  25. EXECUTE FUNCTION SE_BoundingBox ('buildingfootprints', 'footprint');