Skip to content

Instantly share code, notes, and snippets.

@giacecco
Created August 9, 2015 16:57
Show Gist options
  • Save giacecco/9f6c5da3be1b3ed6d32d to your computer and use it in GitHub Desktop.
Save giacecco/9f6c5da3be1b3ed6d32d to your computer and use it in GitHub Desktop.
DROP VIEW IF EXISTS lr_pp_town_definition;
CREATE VIEW lr_pp_town_definition AS
SELECT a.town, ST_MakeEnvelope(MIN(ST_X(b.geom)), MIN(ST_Y(b.geom)), MAX(ST_X(b.geom)), MAX(ST_Y(b.geom)), 4326) AS bounding_box
FROM
(SELECT DISTINCT town, pcd FROM lr_pp) AS a
LEFT JOIN
(SELECT pcd, geom FROM ons_pd WHERE doterm IS NULL) AS b
ON a.pcd = b.pcd
GROUP BY town;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment