Skip to content

Instantly share code, notes, and snippets.

@stuartlynn
Created May 17, 2016 13:31
Show Gist options
  • Select an option

  • Save stuartlynn/b75c2f025fe0ffdc280848d55f288736 to your computer and use it in GitHub Desktop.

Select an option

Save stuartlynn/b75c2f025fe0ffdc280848d55f288736 to your computer and use it in GitHub Desktop.
Demo Chapin House
update  stuartlynn.chicago_gardens_1 set seg_10 = (
      SELECT * from OBS_GetUSCensusCategory(
        the_geom, 
        'Spielman-Singleton Segments: 10 Clusters')
   )
WITH
n(cartodb_id,seg55) AS (
  select cartodb_id, OBS_GetUSCensusCategory(
        the_geom, 
        'Spielman-Singleton Segments: 55 Clusters')
  FROM stuartlynn.chicago_gardens_1
)

UPDATE stuartlynn.chicago_gardens_1 
SET seg_55=n.seg55
FROM n
WHERE n.cartodb_id = stuartlynn.chicago_gardens_1.cartodb_id
WITH
n(cartodb_id, total_pop, median_income, median_age) AS (
  select cartodb_id,
  OBS_GetUSCensusMeasure(the_geom, 'Total Population' ) as pop,
  OBS_GetUSCensusMeasure(the_geom, 'Median Age' ) as age, 
  OBS_GetUSCensusMeasure(the_geom, 'Median Household Income in the past 12 Months' ) as income
where the_geom is not null
  FROM stuartlynn.chicago_gardens_1
)

UPDATE stuartlynn.chicago_gardens_1 
SET seg_55=n.seg55
FROM n
WHERE n.cartodb_id = stuartlynn.chicago_gardens_1.cartodb_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment