ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g
Loading...

Query the Data Delivery Network

Query the DDN

The easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432 and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.

For example, you can query the nyserda_low_to_moderateincome_new_york_state table in this repository, by referencing it like:

"ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest"."nyserda_low_to_moderateincome_new_york_state"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "low_to_moderate_income_group", -- Name of  income group: Very Low Income, Low Income, Moderate Income, or Non-LMI Household. See data dictionary for definition of each income group
    "housing_vintage", -- Age range of house
    "race_ethnicity", -- Name of Race/Ethnicity: Asian, Black, Hispanic, Other, or White
    "income_groups", -- Ranges of annual household income in 2015 dollars
    "head_of_household_age", -- Age range of household head.
    "household_weight", -- The household weight is a number assigned to each record that indicates the number of households in the population that the observation represents.  Because the American Community Survey (ACS) collects information from a sample of households, rather than from all households in the population, the results need to be weighted to generate estimates for the entire population of households.  Each record’s weight does not represent the number of households in the population with the exact same array of all characteristics as that particular sampled household.  Rather, the weights account for the survey sampling and design approach, variation in response the survey across areas, and differences between the sample and external estimates of basic demographic characteristics to produce ACS estimates that conform to population and housing estimates.  The household weights are provided in the ACS microdata files.   More information about the household weight and how it is used for producing statistics can be found here: https://www2.census.gov/programs-surveys/acs/methodology/design_and_methodology/acs_design_methodology_ch11_2014.pdf.
    "county_county_group", -- Name of New York county or a group of New York counties.
    "mortgage_indicator", -- For houses that are owned, indicates if the owner has a mortgage: Yes or No. NA is given for houses that are rented
    "housing_unit_type", -- Housing unit type: 1 - Single Family Attached, 2- Single Family Detached, 3 - Small Multi-Family (2-4 units), 4 - Moderate Multi-Family (5-50 units), 5 - Large Multi-Family (50+ units), or 6 - Mobile Homes & Other
    "household_type", -- Household composition type: Elderly (60+) Head, Elderly (60+) Individual, Older (40-59) with children, Older (40-59) with no children, Younger (Up to 40) with children, or Younger (Up to 40) with no children
    "households_with_children", -- Identifies households with at least one member under the age of 18 years old.
    "lmi_study_region", -- New York study regions developed for this analysis: Central, Eastern, Long Island, NYC I, NYC II, NYC III, or Western
    "households_with_elderly", -- Identifies households with at least one member 60 years of age or older.
    "lmi_population_segment", -- Specific LMI population segments that separate the population on dimensions of income, owner/renter, and housing unit type: #1 – Low-Income Renters in Multifamily (5+ Unit) Buildings, #2 – Moderate-Income Renters in Multifamily (5+ Unit) Buildings, #3 – Low-Income Owners in Single-Family & Small Multifamily (2-4 Unit) Homes, #4 – Moderate-Income Owners of Single-Family & Small Multifamily (2-4 Unit) Homes, #5 – Low-Income Renters in Single-Family & Small Multifamily (2-4 Units) Homes, #6 – Moderate-Income Renters in Single-Family & Small Multifamily (2-4 Units) Homes, #7 – Low/Moderate-Income Owners & Renters in Mobile Homes, #8 – Low/Moderate-Income Owners in Multifamily (5+ Unit) Buildings, or Non-LMI
    "economic_development_region", -- Name of the New York State Economic Development Region.
    "home_energy_payment_method", -- How the household pays the heating fuel bill: Heat included in rent or fee, Only pays non-heat electric direct-to-vendor, or Pays heating bill direct-to-vendor
    "non_elderly_disabled_indicator", -- Identifies households with at least one disabled, non-elderly individual with a “1”, and all other household types with a “0”
    "linguistic_isolation", -- Identifies when no member of the household 16 years or older reported they speak English well or very well: Linguistically Isolated Hispanic, Linguistically Isolated Other, or Not Linguistically Isolated
    "main_heating_fuel_type", -- Main space heating fuel type: 1 - Electric, 2 - Utility Gas, 3 - Fuel Oil, 4 - Propane, 4 - Other Fuels, or 6 - No Fuels Used
    "owner_renter_status", -- Owner-Renter status: Own, Rent/Other
    "percent_of_poverty_level", -- Percent of poverty level group based on household income as a percent of 2015 U.S. Department of Health and Human Services Poverty Guidelines (HHSPG).
    "time_in_home", -- Ranges of length of time (in years) living in home
    "education_level" -- Highest education level achieved by household head: Less than High School Diploma, High School Diploma, Some College, Associate’s, Bachelor’s, or Graduate Degree
FROM
    "ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest"."nyserda_low_to_moderateincome_new_york_state"
LIMIT 100;

Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g with SQL in under 60 seconds.

Query Your Local Engine

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
 

Read the installation docs.

Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.

It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgrcan manage the image, container and volume for you.

There are a few ways to ingest data into the local engine.

For external repositories, the Splitgraph Engine can "mount" upstream data sources by using sgr mount. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.

For hosted datasets (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Cloning Data

Because ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.

First, install Splitgraph if you haven't already.

Clone the metadata with sgr clone

This will be quick, and does not download the actual data.

sgr clone ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g

Checkout the data

Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest tag:

sgr checkout ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest

This will download all the objects for the latest tag of ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.

Alternatively, use "layered checkout" to avoid downloading all the data

The data in ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:

sgr checkout --layered ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g:latest

This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.

Read the layered querying documentation to learn about when and why you might want to use layered queries.

Query the data with your existing tools

Once you've loaded the data into your local Splitgraph Engine, you can query it with any of your existing tools. As far as they're concerned, ny-gov/nyserda-low-to-moderateincome-new-york-state-bui8-bb6g is just another Postgres schema.

Related Documentation:

Loading...