-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
-- First run: | ||
-- pg_dump -t attrs.ztest_university datausa -h postgres.datawheel.us -U postgres -W > /tmp/universities.sql | ||
-- insert into attrs.university (select * from attrs.ztest_university where id not in (select id from attrs.university)) | ||
-- CREATE LOOKUP for each univ | ||
-- 1. pg_dump -t attrs.ztest_university datausa --no-privileges -h postgres.datawheel.us -U postgres -W > /tmp/universities.sql | ||
-- 2. psql < universities.sql | ||
-- 3. Generate university_geo lookup table | ||
CREATE TABLE university_geo AS | ||
SELECT u.id as university, '04000US' || state.geoid as geo | ||
FROM tiger2013.state state, university u | ||
FROM tiger2015.state state, attrs.university u | ||
WHERE ST_Intersects(state.geom, ST_SetSRID(ST_Point(u.lng, u.lat),4326)) | ||
UNION | ||
(SELECT u.id as university, '05000US' || county.geoid as geo | ||
FROM tiger2013.county county, university u | ||
FROM tiger2015.county county, attrs.university u | ||
WHERE ST_Intersects(county.geom, ST_SetSRID(ST_Point(u.lng, u.lat),4326))) | ||
UNION | ||
(SELECT u.id as university, '31000US' || cbsa.geoid as geo | ||
FROM tiger2013.cbsa cbsa, university u | ||
FROM tiger2015.cbsa cbsa, attrs.university u | ||
WHERE ST_Intersects(cbsa.geom, ST_SetSRID(ST_Point(u.lng, u.lat),4326))) | ||
UNION | ||
(SELECT u.id as university, '16000US' || place.geoid as geo | ||
FROM tiger2013.place place, university u | ||
FROM tiger2015.place place, attrs.university u | ||
WHERE ST_Intersects(place.geom, ST_SetSRID(ST_Point(u.lng, u.lat),4326))) | ||
UNION | ||
(SELECT u.id as university, '79500US' || puma.geoid10 as geo | ||
FROM tiger2013.puma puma, university u | ||
FROM tiger2015.puma puma, attrs.university u | ||
WHERE ST_Intersects(puma.geom, ST_SetSRID(ST_Point(u.lng, u.lat),4326))) |