colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw
Icon for Socrata external plugin

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.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.colorado.gov. When you querycolorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

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 (like this repository), 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, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.colorado.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "colorado-gov/census-tracts-sf3-in-colorado-2000-ehbb-wpcw" \
  --handler-options '{
    "domain": "data.colorado.gov",
    "tables": {
        "census_tracts_sf3_in_colorado_2000": "ehbb-wpcw"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

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.