Created
May 19, 2016 15:54
-
-
Save talos/090bc270219e34128cd9754215502e48 to your computer and use it in GitHub Desktop.
NYS grocery store analysis
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
INSERT INTO jkrauss.untitled_table(the_geom, name) | |
SELECT * | |
FROM OBS_GetBoundariesByGeometry( | |
(SELECT ST_SetSRID(ST_MakeEnvelope( | |
MIN(ST_X(the_geom)), | |
MIN(ST_Y(the_geom)), | |
MAX(ST_X(the_geom)), | |
MAX(ST_Y(the_geom)) | |
), 4326) FROM jkrauss.retail_food_stores_fixed), | |
'us.census.tiger.puma_clipped' | |
) As m(the_geom, geoid) | |
WHERE geoid LIKE '36%' | |
ALTER TABLE jkrauss.untitled_table | |
ADD COLUMN grocery_stores NUMERIC; | |
ALTER TABLE jkrauss.untitled_table | |
ADD COLUMN population NUMERIC; | |
UPDATE neighborhoods | |
SET grocery_stores = | |
(SELECT COUNT(*) | |
FROM jkrauss.retail_food_stores_fixed stores | |
WHERE ST_Within(stores.the_geom, neighborhoods.the_geom) | |
AND stores.square_footage > 8000) | |
UPDATE neighborhoods | |
SET population = OBS_GetMeasure(the_geom, 'us.census.acs.B01003001', | |
'area', | |
'us.census.tiger.puma', '2010 - 2014') | |
SELECT cartodb_id, the_geom, the_geom_webmercator, | |
description, grocery_stores, name, | |
population, | |
grocery_stores/population groc_per_pop | |
FROM jkrauss.neighborhoods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment