Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created July 2, 2014 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/6f6d5c79db21e87d0803 to your computer and use it in GitHub Desktop.
Save wboykinm/6f6d5c79db21e87d0803 to your computer and use it in GitHub Desktop.
Match geoid from ACS table to Tiger block groups
DROP TABLE IF EXISTS income_join;
CREATE TABLE
income_join
AS (
WITH table_b19013 AS (
SELECT
substring(geoid FROM 8 FOR 12) geoid,
b19013001
FROM
acs2012_5yr.b19013
WHERE
length(substring(geoid FROM 8 FOR 12)) = 12
)
SELECT
bg.geoid,
bg.the_geom,
bg.namelsad,
acs.b19013001
FROM
tiger2012.bg bg
LEFT OUTER JOIN
table_b19013 acs
ON
(bg.geoid = acs.geoid)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment