colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw
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 census_tracts_sf3_in_colorado_2000 table in this repository, by referencing it like:

"colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw:latest"."census_tracts_sf3_in_colorado_2000"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "the_geom", -- GeoJSON field describing the boundaries of the area
    "objectid", -- The increasing digit unique id for the designated area
    "statefp00", -- The state id number that the designated area is in (Colorado is 08).
    "countyfp00", -- The FIPS County code that the designated area is in (eg 071).
    "tractce00", -- The Tract code that the designated area is in (eg 974800)
    "ctidfp00", -- The ID for the designated area, created by combining the state, county, and tract codes (eg 08051963900)
    "name00", -- The name of the designated area
    "namelsad00", -- The name of the designated area (eg Block Group 3)
    "mtfcc00", -- The MAF/TIGER Feature Class Code, containing data on miscellaneous features. Link: https://www.census.gov/geo/reference/mtfcc.html
    "funcstat00", -- The functional status code. Lookup table available below, page 7. Link: https://www.census.gov/prod/cen2000/doc/ProfilesTD.pdf
    "aland00", -- The amount of water in the designated area, in ft2.
    "awater00", -- The amount of land in the designated area, in ft2.
    "intptlat00", -- The internal latitude point
    "intptlon00", -- The internal longitude point
    "shape_leng", -- The shape perimeter length, in miles
    "shape_area", -- The shape area, in square miles
    "state", -- The state id number that the designated area is in (Colorado is 08).
    "county", -- The FIPS County code that the designated area is in (eg 071).
    "tract", -- The Tract code that the designated area is in (eg 974800)
    "geoidtr", -- The ID for the designated area, created by combining the state, county, and tract codes (eg 08051963900)
    "name10", -- The name of the designated area (eg Block Group 3)
    "pop_sf3", -- The number of people in the designated area
    "hispanic", -- Estimate for the Hispanic Population
    "pcthisp", -- The percentage of people self designated as hispanic (not white).
    "white_nh", -- Estimate for the White, Non-Hispanic Population
    "pctwhite", -- The percentage of people self designated as white (not hispanic).
    "black_nh", -- Estimate for the Black, Non-Hispanic Population
    "pctblack", -- The percentage of people self designated as black (not hispanic)
    "ntv_am_nh", -- The number of people self designated as native american (not hispanic).
    "pctntvam", -- The percentage of people self designated as native american (not hispanic).
    "asian_nh", -- Estimate for the Asian, Non-Hispanic Population
    "pctasian", -- The percentage of people self designated as asian
    "hawpi_nh", -- Estimate for the Hawaiian and Pacific Islander, Non-Hispanic Population
    "pcthaw", -- The percentage of people self designated as hawaiian.
    "other_nh", -- Estimate for the population of those identifying with any other race (Non-Hispanic)
    "pctother", -- The percentage of people self designated as none of the above.
    "twoplus_nh", -- Estimate for the population who identifies with more than one race (Non-Hispanic)
    "pct_twop", -- The percentage of people self designated as multi-ethnic
    "male", -- Estimate for the total male population
    "pct_male", -- The percentage of people self designated as males
    "female", -- Estimate for the total female population
    "pct_female", -- The percentage of people self designated as females
    "ageless10", -- The number of people younger than 10
    "pct_l10", -- The percentage of people younger than 10
    "ageless18", -- Estimate for the total population less than 18 years of age (0 to 17)
    "pct_l18", -- The percentage of people younger than 18
    "age65plus", -- Estimate for the total population 65 years of age or older
    "pct_65pl", -- The percentage of people age 65 and older
    "hhlds", -- The number of households that took part in the survey
    "famhh", -- The number of households self designated as family
    "marcoupfam", -- The number of family households designated as having a husband and wife.
    "oth_fam", -- The number of family households designated as not having a husband and wife.
    "mhhldr_n_w", -- The number of male householder with no wife present
    "fhhldr_n_h", -- The number of female householder with no husband present
    "nonfamhh", -- Estimate for the total number of nonfamily household
    "hhldralone", -- Estimate for the total number of nonfamily households where householder lives alone
    "hhldr_naln", -- Estimate for the total number of nonfamily households where householder does not live alone
    "housingu", -- The number of housing units
    "urbanhu", -- The number of urban housing units
    "pct_urbhu", -- The percentage of housing units that are urban housing units
    "ruralhu", -- The number of rural housing units
    "pct_rurhu", -- The percentage of housing units that are rural housing units
    "occhu", -- The number of occupied housing units
    "pctocc", -- The percentage of housing units that are occupied
    "vachu", -- The number of vacant housing units
    "pctvac", -- The percentage of housing units that are vacant
    "own", -- The number of houses that are owned by their occupants in the designated area
    "pctown", -- The percentage of houses that are owned by their occupants in the designated area
    "rent", -- The number of houses that are rented by their occupants in the designated area
    "pctrent", -- The percentage of houses that are rented by their occupants in the designated area
    "ttlpop25pl", -- The number of residents at least 25 years old
    "no_hs_dipl", -- The number of residents at least 25 years old with no high school diploma
    "pct_nodipl", -- The percentage of residents at least 25 years old with no high school diploma
    "hsgrad_pl", -- The number of residents at least 25 years old with a high school diploma
    "pct_hsplus", -- The percentage of residents at least 25 years old with a high school diploma
    "bachl_hghr", -- Estimated total population 25 years or older with a Bachelors Degree, Masters Degree, Phd or other Professional Degree
    "pct_bachpl", -- The percentage of residents at least 25 years old with at least a bachelors degree
    "medhhinc", -- The median household income
    "medfaminc", -- The median family income
    "percapinc", -- The per capita income
    "medyrblt", -- The median year housing unit built
    "medcrent", -- The median contract rent
    "medgrent", -- The median gross rent
    "medval", -- The median value of a home for owner occupied housing units
    "pop3plus", -- The number of people age 3 years and older
    "enrolled", -- Estimated total population 3+ who are enrolled in school
    "preschool", -- Estimated total population 3+ enrolled in preschool
    "kindrgrtn", -- The number of people enrolled in kindergarten
    "grade_1_4", -- The number of people enrolled in grades 1 through 4
    "grade_5_8", -- The number of people enrolled in grades 5 through 8
    "grade_9_12", -- The number of people enrolled in grades 9 through 12
    "undergrad", -- Estimated total population enrolled in undergraduate studies
    "gradsch", -- The number of people enrolled in graduate courses
    "notinsch", -- The number of people not enrolled in school
    "native", -- The number of persons American born
    "pctnative", -- The percentage of persons American born
    "foreign", -- The number of persons foreign born
    "pctforeign", -- The percentage of persons foreign born
    "pvrty_uni", -- The total number of persons for whom poverty status can be determined
    "in_poverty", -- The number of residents in poverty among those for whom poverty status can be determined
    "pct_pvrty" -- The percentage of residents in poverty
FROM
    "colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw:latest"."census_tracts_sf3_in_colorado_2000"
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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw 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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw: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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw

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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw:latest

This will download all the objects for the latest tag of colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw 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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw: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 colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw: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, colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw is just another Postgres schema.

Related Documentation:

Loading...