Query the Data Delivery Network
Query the DDNThe 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 access_to_intercity_air_bus_and_rail
table in this repository, by referencing it like:
"bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3:latest"."access_to_intercity_air_bus_and_rail"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"uemp_air", -- Percent unemployed (civilian labor force) in rural areas with access to air service
"l10k_air", -- Percent of households in rural areas with access to air service and income less than 10,000 (2018 inflation adjusted dollars)
"popair", -- Rural population within 75 miles of large or medium airport or 25 miles of all other airports with scheduled service.
"all_18c", -- Change in number of non-hub and small airports within 25 miles, medium and large airports within 75 miles, and intercity bus stops and intercity rail facilities within 25 miles of rural area between 2006 and 2021: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"rail_18c", -- Change in number of intercity rail facilities within 25 miles of rural area between 2006 and 2021: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"bus_18c", -- Change in number of intercity bus stops within 25 miles of rural area between 2006 and 2021: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"name", -- County name
"aland", -- Land area square meters
"awater", -- Water area square meters
"hh_bus", -- Households in rural areas with access to intercity bus transportation.
"airl_18c", -- Change in number of medium and large airports within 75 miles of rural area between 2006 and 2021: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"air_18c", -- Change in number of non-hub and small airports within 25 miles and medium and large airports within 75 miles of rural area between 2006 and 2021: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"all_12c", -- Change in number of non-hub and small airports within 25 miles, medium and large airports within 75 miles, and intercity bus stops and intercity rail facilities within 25 miles of rural area in year and closest year 12 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"air_12c", -- Change in number of non-hub and small airports within 25 miles and medium and large airports within 75 miles of rural area in year and closest year 12 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"rail_6c", -- Change in number of intercity rail facilities within 25 miles of rural area in year and closest year 6 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"hh_rail", -- Households in rural areas with access to intercity rail transportation.
"lf_any", -- Civilian labor force in rural areas with access to intercity transportation.
"lf_airl", -- Civilian labor force in rural areas with access to medium or large hub airport.
"lf_bus", -- Civilian labor force in rural areas with access to intercity bus transportation.
"lf_rail", -- Civilian labor force in rural areas with access to intercity rail transportation.
"lf_air", -- Civilian labor force with access to air service.
"p65_anyct", -- Rural population 65 and over with access to any intercity mode
"l10anyct", -- Rural households with income less than $10,000 and access to any intercity mode
"l25anyct", -- Rural households with income less than $25,000 and access to any intercity mode
"uempanyct", -- Civilian labor force in rural areas that is unemployed and has access to any intercity mode
"p65airct", -- Rural population 65 and over with access to air transportation
"p65airlct", -- Rural population 65 and over with access to medium or large hub airport
"p65busct", -- Rural population 65 and over with access to intercity bus transportation
"p65railct", -- Rural population 65 and over with access to intercity rail transportation
"p65ct", -- Rural population 65 and over
"l10airct", -- Rural households with income less than $10,000 and access to air transportation
"l10airlct", -- Rural households with income less than $10,000 and access to medium or large hub airport
"l10raict", -- Rural households with income less than $10,000 and access to intercity rail transportation
"l10kct", -- Rural households with income less than $10,000
"l25airct", -- Rural households with income less than $25,000 and access to air transportation
"l25ailct", -- Rural households with income less than $25,000 and access to medium or large hub airport
"l25busct", -- Rural households with income less than $25,000 and access to intercity bus transportation
"l25raict", -- Rural households with income less than $25,000 and access to intercity rail transportation
"l25kct", -- Rural households with income less than $25,000
"povairct", -- Rural households below poverty and access to air transportation
"povailct", -- Rural households below poverty and access to medium or large hub airport
"povbusct", -- Rural households below poverty and access to intercity bus transportation
"v0airct", -- Rural households with no access to household vehicle but access to air transportation
"v0airlct", -- Rural households with no access to household vehicle but access to medium or large hub airport
"v0busct", -- Rural households with no access to household vehicle but access to intercity bus transportation
"v0railct", -- Rural households with no access to household vehicle but access to intercity rail transportation
"uemairct", -- Civilian labor force in rural areas that is unemployed and has access to air transportation
"uemailct", -- Civilian labor force in rural areas that is unemployed and has access to medium or large hub airport
"uembusct", -- Civilian labor force in rural areas that is unemployed and has access to intercity bus transportation
"uemraict", -- Civilian labor force in rural areas that is unemployed and has access to intercity rail transportation
"bus_6c", -- Change in number of intercity bus stops within 25 miles of rural area in year and closest year 6 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"uempct", -- Civilian labor force in rural areas that is unemployed
"povanyct", -- Rural households below poverty and access to any intercity mode
"povct", -- Rural households below poverty
"v0anyct", -- Rural households with no access to household vehicle but access to any intercity mode
"hh_v0ct", -- Rural households with no access to household vehicle
"var", -- Variation description
"var_num", -- Variation number
"abinall", -- Bin used to map PAccessAll: 999=population data NA; 998: no rural population; 0: no access; 1: <25 percent; 2: 25<=percent access<50; 3: 50<=percent access<75; 4: 75<=percent access<99; 5: percent access=100
"abinrail", -- Bin used to map PAccessRail: 999=population data NA; 998: no rural population; 0: no access; 1: <25 percent; 2: 25<=percent access<50; 3: 50<=percent access<75; 4: 75<=percent access<99; 5: percent access=100
"abinair", -- Bin used to map PAccessAir: 999=population data NA; 998: no rural population; 0: no access; 1: <25 percent; 2: 25<=percent access<50; 3: 50<=percent access<75; 4: 75<=percent access<99; 5: percent access=100
"cntall", -- Number of non-hub and small airports within 25 miles of rural area and medium and large airports within 75 miles of rural area and intercity bus and intercity rail stops within 25 miles of rural area (includes airports, intercity bus stops, and intercity rail facilities outside of county)
"cntbus", -- Number of intercity bus stops within 25 miles of rural area (includes stops outside of county)
"cntairl", -- Number of medium and large airports within 75 miles of rural area (includes airports outside of county)
"cntair", -- Number of non-hub and small airports within 25 miles of rural area and medium and large airports within 75 miles of rural area (includes airports outside of county)
"paccall", -- Percent of rural population within 25 miles of non-hub or small airport, 75 miles of a medium or large airport, or 25 miles of intercity bus stop or intercity rail station
"paccrail", -- Percent of rural population within 25 miles of intercity rail station
"paccbus", -- Percent of rural population within 25 miles of intercity bus stop
"paccairl", -- Percent of rural population within 75 miles of a medium or large airport
"paccair", -- Percent of rural population within 25 miles of non-hub or small airport or 75 miles of a medium or large airport
"y", -- Centroid of county, latitude
"x", -- Centriod of county, longitude
"statepo", -- State abbreviation
"popbase", -- Dataset for population data
"totpop", -- Total population
"ruralpop", -- Total population living in rural block groups
"totbg", -- Total number of block groups
"cbsafp", -- Core based statistical area identifier if county lies within single CBSA
"the_geom", -- shape
"ruralbg", -- Number of rural block groups
"year", -- Year of data
"cntrail", -- Number of intercity rail facilities within 25 miles of rural area (includes facilities outside of county)
"hh_airl", -- Households in rural areas with access to medium or large hub airport.
"hh_air", -- Households in rural areas with access to air service.
"hh_any", -- Households in rural areas with access to intercity transportation
"v0", -- Percent of zero vehicle households in rural areas
"v0_rail", -- Percent of zero vehicle households in rural areas with access to rail transportation
"v0_bus", -- Percent of zero vehicle households in rural areas with access to intercity bus transportation
"v0_airl", -- Percent of zero vehicle households in rural areas with access to medium or large hub airport
"v0_air", -- Percent of zero vehicle households in rural areas with access to air service
"v0_any", -- Percent of zero households in rural areas with access to intercity transportation
"bin_v0", -- Bin used for mapping percent of zero vehicle households in rural areas (998=no rural population, 999=no population data, 0=0, 1=1 to 4.9%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"bin_l25k", -- Bin used for mapping percent of households in rural areas with in income less than 25,000 (998=no rural population, 999=no population data, 0=0, 1=1 to 4.9%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"l25k", -- Percent of households in rural areas with income less than 25,000
"l25k_rail", -- Percent of households in rural areas with access to intercity rail transportation and income less than 25,000 (2018 inflation adjusted dollars)
"l25k_bus", -- Percent of households in rural areas with access to intercity bus transportation and income less than 25,000 (2018 inflation adjusted dollars)
"l25kairl", -- Percent of households in rural areas with access to medium or large hub airport and income less than 25,000 (2018 inflation adjusted dollars)
"l25k_air", -- Percent of households in rural areas with access to air service and income less than 25,000 (2018 inflation adjusted dollars)
"l25k_any", -- Percent of households in rural areas with access to intercity transportation and income less than 50,000 (2018 inflation adjusted dollars)
"p65_any", -- Percent 65 and older in rural areas with access to intercity transportation
"bin_uemp", -- Bin used for mapping percent of civilian labor force in rural areas unemployed (998=no rural population, 999=no population data, 0=0%, 1=less than 5%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"bin_l10k", -- Bin used for mapping households in rural areas with income less than 10,000 (998=no rural population, 999=no population data, 0=0%, 1=less than 5%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"bin_pov", -- Bin used for mapping percent of households in rural areas below poverty (998=no rural population, 999=no population data, 0=0%, 1=less than 5%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"bin_p65", -- Bin for mapping percent of population in rural areas that is 65 and older (998=no rural population, 999=no population data, 0=0%, 1=less than 5%, 2=5 to 9.9%, 3=10 to 14.9%, 4=15 to 19.9%, 5=20 to 24.9%, 6=25% or more)
"uemp", -- Percent of civilian labor force in rural areas unemployed
"l10k", -- Percent of households in rural areas with income less than 10,000
"pov", -- Percent of households in rural areas below poverty
"p65", -- Percent of population in rural areas 65 or older
"uemprail", -- Percent unemployed (civilian labor force) in rural areas with access to intercity rail transportation
"l10krail", -- Percent of households in rural areas with access to intercity rail transportation and income less than 10,000 (2018 inflation adjusted dollars)
"pov_rail", -- Percent of households below poverty in rural areas with access to intercity rail transportation
"p65_rail", -- Percent 65 and older in rural areas with access to intercity rail transportation
"uemp_bus", -- Percent unemployed (civilian labor force) in rural areas with access to intercity bus transportation
"l10k_bus", -- Percent of households in rural areas with access to intercity bus transportation and income less than 10,000 (2018 inflation adjusted dollars)
"pov_bus", -- Percent of households below poverty in rural areas with access to intercity bus transportation
"p65_bus", -- Percent 65 and older in rural areas with access to intercity bus transportation
"uempairl", -- Percent unemployed (civilian labor force) in rural areas with access to medium or large hub airport
"l10kairl", -- Percent of households in rural areas with access to medium or large hub airport and income less than 10,000 (2018 inflation adjusted dollars)
"pov_airl", -- Percent of households below poverty in rural areas with access to medium or large hub airport
"p65_airl", -- Percent 65 and older in rural areas with access to medium or large hub airport
"pov_air", -- Percent of households below poverty in rural areas with access to air service
"p65_air", -- Percent 65 and older in rural areas with access to air service
"uemp_any", -- Percent unemployed (civilian labor force) in rural areas with access to intercity transportation
"abinairl", -- Bin used to map PAccessAirLarge: 999=population data NA; 998: no rural population; 0: no access; 1: <25 percent; 2: 25<=percent access<50; 3: 50<=percent access<75; 4: 75<=percent access<99; 5: percent access=100
"abinbus", -- Bin used to map PAccessBus: 999=population data NA; 998: no rural population; 0: no access; 1: <25 percent; 2: 25<=percent access<50; 3: 50<=percent access<75; 4: 75<=percent access<99; 5: percent access=100
"air_6c", -- Change in number of non-hub and small airports within 25 miles and medium and large airports within 75 miles of rural area in year and closest year 6 years prior: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"airl_6c", -- Change in number of medium and large airports within 75 miles of rural area in year and closest year 6 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"all_6c", -- Change in number of non-hub and small airports within 25 miles, medium and large airports within 75 miles, and intercity bus stops and intercity rail facilities within 25 miles of rural area in year and closest year 6 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"l10k_any", -- Percent of households in rural areas with access to intercity transportation and income less than 10,000 (2018 inflation adjusted dollars)
"airl_12c", -- Change in number of medium and large airports within 75 miles of rural area in year and closest year 12 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"bus_12c", -- Change in number of intercity bus stops within 25 miles of rural area in year and closest year 12 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"rail_12c", -- Change in number of intercity rail facilities within 25 miles of rural area in year and closest year 12 years prior: -3: loss of 3 or more; -2: loss of 2; -1: loss of 1; 0: no change; 1: gain of 1; 2: gain of 2; 3: gain of 3 or more; 999: NA
"pov_any", -- Percent of households below poverty in rural areas with access to intercity transportation
"popall", -- Rural population within 75 miles of large or medium airport or 25 miles from another airport with scheduled service or 25 miles of intercity bus stop or rail facility.
"lf", -- Count of persons in civilian labor force in rural areas
"l10busct", -- Rural households with income less than $10,000 and access to intercity bus transportation
"hh", -- Count of households in rural areas
"povraict", -- Rural households below poverty and access to intercity rail transportation
"poprail", -- Rural population within 25 miles of intercity rail facility.
"statefp", -- State identifier
"popbus", -- Rural population within 25 miles of intercity bus stop.
"countyfp", -- County identifier
"popairl", -- Rural population within 75 miles of large or medium airport with scheduled service.
"geoid" -- State + county identifier
FROM
"bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3:latest"."access_to_intercity_air_bus_and_rail"
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 bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3: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 bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3
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 bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3:latest
This will download all the objects for the latest
tag of bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3
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 bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3: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 bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3: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, bts-gov/access-to-intercity-air-bus-and-rail-m2bh-93w3
is just another Postgres schema.