Created
October 23, 2015 07:39
-
-
Save renzok/3fd2071038d74f6af5fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE MATERIALIZED VIEW osdregistry.sample_boundaries_tagging AS | |
WITH boundary AS ( | |
SELECT DISTINCT ON (osd.submission_id) | |
osd.submission_id, | |
osd.osd_id, | |
b.gid, | |
b.iso3_code, | |
st_distance(osd.start_geog, b.geog) as dist_m | |
FROM elayers.boundary_polygons b | |
JOIN osdregistry.samples osd | |
ON ( st_dwithin(osd.start_geog, b.geog, 1000000::double precision) ) | |
ORDER BY osd.submission_id, st_distance(osd.start_geog, b.geog) | |
) | |
SELECT * | |
FROM boundary b | |
ORDER BY b.osd_id DESC | |
; | |
ALTER TABLE osdregistry.sample_boundaries_tagging | |
OWNER TO megdb_admin; | |
GRANT ALL ON TABLE osdregistry.sample_boundaries_tagging TO megdb_admin; | |
GRANT SELECT ON TABLE osdregistry.sample_boundaries_tagging TO megx_team WITH GRANT OPTION; | |
COMMENT ON MATERIALIZED VIEW osdregistry.sample_boundaries_tagging | |
IS 'Distance to OSD sampling site to nearest country border taken as coastline based on elayers.boundaries.'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment