colorado-gov/highway-traffic-counts-in-colorado-2018-56kc-gpid
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 highway_traffic_counts_in_colorado_2018 table in this repository, by referencing it like:

"colorado-gov/highway-traffic-counts-in-colorado-2018-56kc-gpid:latest"."highway_traffic_counts_in_colorado_2018"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "the_geom", -- Auto generated field containing the geometry of each item. Users note that this field may or may not be completely accurate. It is recommended for the user to run a separate analysis.
    "route", -- A Unique (3 Number - 1 Letter) Highway Identification Code or Designating for a State Highway, Business Route, U.S. Route or Tolled Facility. Odd numbers typically run North and South and Even numbers typically Run East and West.
    "refpt", -- A Linear Reference Number or Address Key (to the Thousandth of a Mile) Representing the Starting Point of a roadway segment. A Unique Landmark Location (not the running measure) or (maybe a one-time true measure) of a roadway segment along a State Route.
    "endrefpt", -- A Linear Reference Number or Address Key (to the Thousandth of a Mile) Representing the Ending Point of a roadway Segment. A Unique Landmark Location (not the running measure) or (maybe a one-time true end measure) of a segment along a State Route.
    "runlength_",
    "runlength1",
    "length_", -- The Centerline Segment Length or Segment Distance (in Miles) to the Thousandth of a Mile. Length_ is the distance from one Road Segment to the next Road Segment. Length_ is a dimension or measurement that is carried out 3-decimal places.
    "updateyr", -- The last calendar year in which the data was updated.
    "countstati",
    "aadt", -- The annual average daily traffic count for the segment. (Total of all vehicles counted in a year divided by 365 days)
    "aadtcomb", -- The AADT consisting of combination trucks (3 or more axles-single trailer or multiple trailers).
    "aadtderiv", -- A Domained Value Element (AADTDeriv) indicating the Code Associated with the Factoring Method used in calculating the AADT determination Value.
    "aadtsingle", -- The AADT consisting of single unit trucks (vehicles larger than pickup trucks built on a single chassis).
    "aadttrucks", -- Annual Average Daily Traffic for Trucks
    "aadtyr", -- The calendar year (YYYY) in which the annual average daily traffic count applies for the highway segment.
    "calyr", -- The last calendar year in which the data was updated.
    "countyear", -- The year the data was recorded
    "dd", -- Directional Distribution -The percentage of the design hour value flowing in the peak direction.
    "dhv", -- The 30th highest annual hourly traffic volume expressed as a percentage of AADT
    "edla", -- Equivalent Daily Load Axle
    "offpktrk", -- The Peak percent of AADT that is composed of trucks of all types. Calculated by taking the number of trucks divided by the AADT
    "pctoffpkco", -- Percentage of AADT for Combination Trucks During Off-Peak Periods
    "pctoffpksu", -- Percentage of AADT for Single Unit Trucks During Off-Peak Periods
    "pctpksu", -- Percentage of AADT for single unit trucks during the Peak Hour.
    "pctpkcomb", -- Percentage of AADT for Combination Trucks During the Peak Hour.
    "pktrk", -- The Peak percent of AADT that is composed of trucks of all types. Calculated by taking the number of trucks divided by the AADT
    "routecapac", -- The maximum number of vehicles which has a reasonable expectation of passing over a given section of lane or roadway during a given time period under prevailing roadway and traffic conditions per the Highway Capacity Manual.
    "vcratio", -- The hourly traffic volume divided by the capacity of the segment. Thus, the volume/capacity ratio measure can be assumed to measure capacity sufficiency and delay is a measure of the quality of service.
    "vcratio20", -- The 20 year projection for the VCRATIO value.
    "yr20factor", -- A traffic forecasting statistic that gives an estimate of AADT for 20 years in the future.
    "roadterrai", -- A Domained Value Element (terrain 0-3) used to identify the Predominant type of terrain through which the road segment passes as specified by AASHTO.
    "seasonalgr", -- A Domained Numeric Designation (seasonalGroupID, 1-7) indicating the Coded Value associated with a list of Seasonal Variations used for short term data calculations.
    "isramp"
FROM
    "colorado-gov/highway-traffic-counts-in-colorado-2018-56kc-gpid:latest"."highway_traffic_counts_in_colorado_2018"
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/highway-traffic-counts-in-colorado-2018-56kc-gpid 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/highway-traffic-counts-in-colorado-2018-56kc-gpid: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/highway-traffic-counts-in-colorado-2018-56kc-gpid

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/highway-traffic-counts-in-colorado-2018-56kc-gpid:latest

This will download all the objects for the latest tag of colorado-gov/highway-traffic-counts-in-colorado-2018-56kc-gpid 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/highway-traffic-counts-in-colorado-2018-56kc-gpid: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/highway-traffic-counts-in-colorado-2018-56kc-gpid: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/highway-traffic-counts-in-colorado-2018-56kc-gpid is just another Postgres schema.

Related Documentation:

Loading...