NYCPlanning / db-factfinder

data ETL for population fact finder (decennial + acs)
https://nycplanning.github.io/db-factfinder/factfinder/
MIT License
2 stars 3 forks source link

Thematic Map SQL query #207

Closed SPTKL closed 2 years ago

SPTKL commented 3 years ago

Context: Quick update from our meeting with Joel today to get the conversation started for next week while I'm away. We think that our work on ACS data is done 🎉. Traditionally, you've checked the data in the app, but given that there's a delay in getting the data into the app Molly and Baiyue will be working to create digestible tables for you to review so that you can sign-off on the data. Your input on what information to report and how would be useful, and we can iterate off what Molly started mocking up.

Labs is working on implementing the thematic map feature for NTAs in PFF. Where did the current data driving this part of PFF come from? Did you create a separate table to drive this feature? If so, do you plan to create a dedicated table again? Can this be generated from the data Data Engineering creates?

SELECT 
    _popu181.geoid,
    support_geoids."label",
    _popu181.popu181,
    _mdgr.mdgr,
    _pbwpv.pbwpv,
    _pbwpv.pbwpv_p,
    _lgoenlep1.lgoenlep1,
    _fb1.fb1_p,
    _ea_bchdh.ea_bchdh,
    _ea_bchdh.ea_bchdh_p,
    _pop65pl1.pop65pl1
FROM (
    SELECT geoid, e as popu181 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'popu181'
) _popu181 

LEFT JOIN (
    SELECT geoid, e as mdgr 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'mdgr'
) _mdgr ON _popu181.geoid = _mdgr.geoid

LEFT JOIN (
    SELECT geoid, e as pbwpv, p as pbwpv_p 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'pbwpv'
) _pbwpv ON _popu181.geoid = _pbwpv.geoid

LEFT JOIN (
    SELECT geoid, e as lgoenlep1
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'lgoenlep1'
) _lgoenlep1 ON _popu181.geoid = _lgoenlep1.geoid

LEFT JOIN (
    SELECT geoid, p as fb1_p 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'fb1'
) _fb1 ON _popu181.geoid = _fb1.geoid

LEFT JOIN (
    SELECT geoid, e as ea_bchdh, p as ea_bchdh_p 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'ea_bchdh'
) _ea_bchdh ON _popu181.geoid = _ea_bchdh.geoid

LEFT JOIN (
    SELECT geoid, e as pop65pl1 
    FROM acs."2019" 
    WHERE geotype LIKE 'NTA%' 
    AND variable = 'pop65pl1'
) _pop65pl1 ON _popu181.geoid = _pop65pl1.geoid

LEFT JOIN support_geoids 
ON _popu181.geoid = support_geoids.geoid
WHERE support_geoids.geotype LIKE 'NTA%';
SPTKL commented 3 years ago

@EricaMaurer you can find them here lgoenlep is NULL for all tables below cdta_choropleth_0610.csv cdta_choropleth_1519.csv nta_choropleth_0610.csv nta_choropleth_1519.csv

EricaMaurer commented 3 years ago

@SPTKL Thematic maps for this round should just be for the 2015-2019 ACS (not 2006-2010) and Decennial-- so the other three csv files you created are not needed.

Not sure what part you are doing vs part Labs is doing so will put all the information here for the variables and map breaks.

ACS maps:

-- mdgr --- 2500 - 9999999 --- 2000 - 2499 --- 1500 - 1999 --- 1200 - 1499 --- 0 - 1199

-- pbwpv --- 21000 - 9999999 --- 15000 - 20999 --- 10000 - 14999 --- 5000 - 9999 --- 0 - 4999

Decennial maps:

SPTKL commented 3 years ago

thanks @EricaMaurer this is super helpful! CC @NYCPlanning/engineering @godfreyyeung @TylerMatteo

EricaMaurer commented 3 years ago

Info box text change for Median Gross Rent: Median gross rent (in 2019 inflation-adjusted dollars)

Legend/info box text for maps-- these maps will appear under Census heading:

Population (info box: Total population, 2020) 85,000 or more 70,000 to 84,999 55,000 to 69,999 40,000 to 54,999 30,000 to 39,999 Less than 30,000

Population Density (current breaks, labeling, and info box)

Use Map Breaks for: White Non-Hispanic (info box: White non-Hispanic population, 2020) Black Non-Hispanic (info box: Black non-Hispanic population, 2020) Asian Non-Hispanic (info box: Asian non-Hispanic population, 2020) Hispanic (info box: Hispanic population, 2020) 40,000 or more 30,000 to 39,999 20,000 to 29,999 10,000 to 19,999 5,000 to 9,999 Less than 5,000

Use Map Breaks for: White Non-Hispanic (percent) (info box: Percent of the population that is White non-Hispanic, 2020) Black Non-Hispanic (percent) (info box: Percent of the population that is Black non-Hispanic, 2020) Asian Non-Hispanic (percent) (info box: Percent of the population that is Asian non-Hispanic, 2020) Hispanic (percent) (info box: Percent of the population that is Hispanic, 2020) 80% or more 65% to 79% 50% to 64% 35% to 49% 20% to 34% Less than 20%

Use Map Breaks for: Population (change) (info box: Population change, 2010 to 2020) Gain of 10,000 or more (HEX: #012661) 5,000 to 9,999 (#0B5476) 1,000 to 4,999 (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

White Non-Hispanic (change) (info box: White non-Hispanic population change, 2010 to 2020) Gain of 10,000 or more (HEX: #012661) 5,000 to 9,999 (#0B5476) 1,000 to 4,999 (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

Black Non-Hispanic (change) (info box: Black non-Hispanic population change, 2010 to 2020) 1,000 or more (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

Asian Non-Hispanic (change) (info box: Asian non-Hispanic population change, 2010 to 2020) Gain of 10,000 or more (HEX: #012661) 5,000 to 9,999 (#0B5476) 1,000 to 4,999 (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

Hispanic (change) (info box: Hispanic population change, 2010 to 2020) 5,000 or more (#0B5476) 1,000 to 4,999 (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

Under 18 (change) (info box: Change in population under 18 years, 2010 to 2020) 5,000 or more (#0B5476) 1,000 to 4,999 (#0473AD) 500 to 9,999 (#B5D5E5) -499 to 499 (#FFFFFF) -500 to -999 (#FFC0B4) -4,999 to -1,000 (#F46C59) Loss of 5,000 or more (#C81D00)

Use breaks for percent change maps (remove NTAs with less than 5,000 for each group in 2020-- if it can't be easily filtered, I can provide exact data for these maps): Population (percent change) (info box: Percent change in population, 2010 to 2020)-- (remove NTAs with less than 5,000 population in 2020-- if it can't be easily filtered, I can provide data) Gain of 50% or more (HEX: #012661) 25% to 49% (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) Loss of 5% or more (#FFC0B4)

White Non-Hispanic (percent change) (info box: Percent change in the White Non-Hispanic population, 2010 to 2020)-- (remove NTAs with less than 5,000 White NH in 2020-- if it can't be easily filtered, I can provide data) Gain of 50% or more (HEX: #012661) 25% to 49% (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) -9% to -5% (#FFC0B4) -14% to -10% (#F46C59) Loss of 15% or more (#C81D00)

Black Non-Hispanic (percent change) (info box: Percent change in the Black Non-Hispanic population, 2010 to 2020)-- (remove NTAs with less than 5,000 Black NH in 2020-- if it can't be easily filtered, I can provide data) Gain of 25% or more (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) -9% to -5% (#FFC0B4) -14% to -10% (#F46C59) Loss of 15% or more (#C81D00)

Asian Non-Hispanic (percent change) (info box: Percent change in the Asian Non-Hispanic population, 2010 to 2020)-- (remove NTAs with less than 5,000 Asian NH in 2020-- if it can't be easily filtered, I can provide data) Gain of 50% or more (HEX: #012661) 25% to 49% (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) -9% to -5% (#FFC0B4) -14% to -10% (#F46C59) Loss of 15% or more (#C81D00)

Hispanic (percent change) (info box: Percent change in the Hispanic population, 2010 to 2020)-- (remove NTAs with less than 5,000 Hispanic in 2020-- if it can't be easily filtered, I can provide data) Gain of 50% or more (HEX: #012661) 25% to 49% (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) -9% to -5% (#FFC0B4) -14% to -10% (#F46C59) Loss of 15% or more (#C81D00)

Under 18 (percent change) (info box: Percent change in the population under 18 years, 2010 to 2020)-- (remove NTAs with less than 5,000 under 18 in 2020-- if it can't be easily filtered, I can provide data) Gain of 50% or more (HEX: #012661) 25% to 49% (#0B5476) 15% to 24% (#0473AD) 10% to 14% (#5FA4CB) 5% to 9% (#B5D5E5) -4% to 4% (#FFFFFF) -9% to -5% (#FFC0B4) -14% to -10% (#F46C59) Loss of 15% or more (#C81D00)

Under 18 (info box: Population under 18 years, 2020) 25,000 or more 20,000 to 24,999 15,000 to 19,999 10,000 to 14,999 Less than 10,000

Under 18 (percent) (info box: Percent of the population under 18 years, 2020) 30% or more 25% to 29% 20% to 24.9 15% to 19% Less than 15%

CC @NYCPlanning/engineering @godfreyyeung @TylerMatteo