open-austin / atx-citysdk-js

:fork_and_knife: A demo of citysdk-js
http://open-austin.github.io/atx-citysdk-js/
The Unlicense
2 stars 4 forks source link

Gather the right Demographic variables from Census API #9

Open mateoclarke opened 9 years ago

mateoclarke commented 9 years ago

For each Census Tract, we need metrics for at least:

The CitySDK query builder has a handful of variables listed but it looks like we need to dig into the Census API Docs for the right values.

We also may need to sum a list of values (like for Ages 0-5 + Ages 6-10 + Ages 11-15 + ...)

Also, is it better to use the ACS 3 year or 5 year survey? I was looking at the 3 year for 2013.

Can you point me in the right direction @jmeisel?

jmeisel commented 9 years ago

Hi Mateo -

  1. Your best bet is to use variables that represent "Data Profiles", or key statistics from the ACS. These appear as "DP" when you look at the API Docs. These normally have total count and also percentage, if you prefer. The percentage is nice for doing heatmaps and that type of thing, and it saves you the coding hassle of manually doing division and ratios.
  2. In terms of the 1 vs. 3 vs. 5 year, the 3 year is probably ok for this particular use-case. I will save you the detailed explanation, but there are different merits for choosing between the three. Happy to dive into it later.

The ACS 3 Year for 2013 can provide you the following variables, which I looked up here: http://api.census.gov/data/2013/acs3/profile/variables.html

Total Population (count) DP05_0001E

Percent of Population in Elementary School -> i.e. does area have a lot of kids, similar to your question under 16 (or 18) DP02_0055PE -> includes grades 1-8

Percent of Multi-family homes vs. single units Sum the following to get total multifamily percentage DP04_0009PE -> 2 units DP04_0010PE -> 3 or 4 units DP04_0011PE -> 5 to 9 units DP04_0012PE -> 10 to 19 units DP04_0013PE -> 20 or more units

Poverty Rate DP03_0119PE -> Percentage of families below poverty line

Percentage of population that has health insurance DP03_0096PE

Let me know if this helps, happy to keep narrowing in on the right variables with you.

Jeff

mateoclarke commented 9 years ago

:smile_cat: puuuurfect. Thanks! This seems like exactly what I needed. I'll let you know if I get stuck on something.

mateoclarke commented 9 years ago

Hey @jmeisel , I'm having an trouble getting an API response that doesn't error.

This is the call I'm making: http://api.census.gov/data/2013/acs3?get=NAME,B19013_001E,B01003_001E,B17001_002E,DP05_0001E,DP02_0055PE,DP04_0009PE,DP04_0010PE,DP04_0011PE,DP04_0012PE,DP04_0013PE,DP03_0119PE,DP03_0096PE&for=tract:*&in=county:453+state:48&key=58211e2426331117ab16deabbfe10b226b95b61b

And the error I'm getting is: error: error: unknown variable 'DP05_0001E'

This is what my request looks like in app.js:

var sdk = new CitySDK();
var censusModule = sdk.modules.census;
censusModule.enable(config.citySDK_token);

var request = {
  "lat": config.city_lat,
  "lng": config.city_lng,
  "level": "county",
  "sublevel": "true",
  "year" : 2013,
  "api" : "acs3",
  "variables": [
    "income",
    "population",
    "poverty",
    "DP05_0001E",  // 1. Total Population
    "DP02_0055PE", // 2. Percent of Population in Elementary School
                   // 3. Percent of Multi-family homes vs. single units
    "DP04_0009PE", //   2 units
    "DP04_0010PE", //   3 or 4 units
    "DP04_0011PE", //   5 to 9 units
    "DP04_0012PE", //   10 to 19 units
    "DP04_0013PE", //   20 or more units
    "DP03_0119PE", // 4. Percentage of families below poverty line
    "DP03_0096PE"  // 5. Percentage of population that has health insurance
  ]
};

censusModule.APIRequest(request, function (response) {
  window.CensusData = response;
});
jmeisel commented 9 years ago

Hey Mateo - let me loop in David my teammate to see if he can assist in debugging. (via email)

Jeff

On Tue, Sep 29, 2015 at 12:24 PM, Mateo Clarke notifications@github.com wrote:

Hey @jmeisel https://github.com/jmeisel , I'm having an trouble getting an API response that doesn't error.

This is the call I'm making:

http://api.census.gov/data/2013/acs3?get=NAME,B19013_001E,B01003_001E,B17001_002E,DP05_0001E,DP02_0055PE,DP04_0009PE,DP04_0010PE,DP04_0011PE,DP04_0012PE,DP04_0013PE,DP03_0119PE,DP03_0096PE&for=tract:*&in=county:453+state:48&key=58211e2426331117ab16deabbfe10b226b95b61b

And the error I'm getting is: error: error: unknown variable 'DP05_0001E'

This is what my request looks like in app.js:

var sdk = new CitySDK(); var censusModule = sdk.modules.census; censusModule.enable(config.citySDK_token);

var request = { "lat": config.city_lat, "lng": config.city_lng, "level": "county", "sublevel": "true", "year" : 2013, "api" : "acs3", "variables": [ "income", "population", "poverty", "DP05_0001E", // 1. Total Population "DP02_0055PE", // 2. Percent of Population in Elementary School // 3. Percent of Multi-family homes vs. single units "DP04_0009PE", // 2 units "DP04_0010PE", // 3 or 4 units "DP04_0011PE", // 5 to 9 units "DP04_0012PE", // 10 to 19 units "DP04_0013PE", // 20 or more units "DP03_0119PE", // 4. Percentage of families below poverty line "DP03_0096PE" // 5. Percentage of population that has health insurance ] };

— Reply to this email directly or view it on GitHub https://github.com/open-austin/atx-citysdk-js/issues/9#issuecomment-144127703 .

jmeisel commented 9 years ago

@mateoclarke After spending an hour testing, my recommendation is the following:

  1. Use 5 Year ACS and only the B variables. I made a simple Gist to test this out: https://gist.github.com/jmeisel/2574d3f192ffff5a366d

There is something up when using CitySDK with the 3-Year and DP variables and I haven't root caused it. Making your requests like this using the 5-Year, Aliases, and B variables works fine though:

       var request = {
            zip: zip.val(),
            api: "acs5",
            variables: [
                "population",
                "income",
                "poverty_family",
                "B01001_004E",
                "B01001_028E"

            ],
            level: $("#level option:selected").val()
        }

This returns something like this:

ZIP: 78756 Coordinates: +30.3222297, -097.7401666 Population 3233 Median Income: 60456 Number of Families Below Poverty 20 Male Ages 5-9 34 Female Ages 5-9 140

Here's the API doc that describes which variables are available: http://api.census.gov/data/2013/acs5/variables.html

  1. Or if you still want to use ACS 3-Year and the variables I provided previously, you should be able to call the Census API directly (without using CitySDK). Let me know if I can help further.
mateoclarke commented 9 years ago

Hey @jmeisel, thanks for trying to debug. This got me 90% of the way there. I'm having trouble finding an appropriate measure of housing density in http://api.census.gov/data/2013/acs5/variables.html

There are just so many variables in the table it's hard to find exactly what you are looking for. I tried "Units in Structure" but most of those deal with tenure, ownership, or cost. Could be overlooking something.

jmeisel commented 9 years ago

@mateoclarke Housing Units should be this variable: "B25001_001E"

Example request via the variable tester code (provided in the gist above)

        var request = {
            zip: zip.val(),
            "api": "acs5",
            variables: [
                "population",
                "income",
                "poverty_family",
                "B01001_004E",
                "B01001_028E", 
                "B25001_001E",
            ],
        }

Return values:

ZIP: 78756 Coordinates: +30.3222297, -097.7401666 Population 1337 Median Income: 70563 Number of Families Below Poverty null Male Ages 5-9 34 Female Ages 5-9 110 Unweighted Housing Units 657

jmeisel commented 9 years ago

@mateoclarke Also I am in the midst of building some tools to help alleviate the painpoint of trying to search those huge variable files to find what you are looking for... I realize that is very annoying.

mateoclarke commented 9 years ago

:+1: