edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h
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 driver_feedback_sign_dfs007 table in this repository, by referencing it like:

"edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h:latest"."driver_feedback_sign_dfs007"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "vehicle_count_at_slowest_speed_detected", -- The number of vehicles counted in the 15 minute time interval where the detected slowest speed of the vehicle was equal to or greater than the Minimum Speed for the Bin and is less than or equal to the Maximum Speed for the Bin.
    "location_description", -- A brief / abbreviated description of the location where the DFS unit is located.
    "vehicle_count_at_highest_speed_detected", -- The number of vehicles counted in the 15 minute time interval where the detected fastest speed of the vehicle was equal to or greater than the Minimum Speed for the Bin and is less than or equal to the Maximum Speed for the Bin.
    "minimum_speed_for_bin_number", -- The slowest detected speed travelled that corresponds to the Bin Number.  Vehicles can travel equal to or faster than this speed for it to be recorded for the Bin.  NOTE: For Bin 1, the minimum detectable speed is approximately 6 KPH.
    "vehicle_count_for_log_interval", -- The number of vehicles that were successfully detected and recorded within the specified parameters.  This Vehicle Count is not and should not be correlated to a traffic volume count within the 15 minute interval.
    "log_timestamp", -- The Timestamp of when the data was recorded.  The time interval between recordings is 15 minutes.  Note: It is possible to not have a specific recording of data at a specific Timestamp.  This can occur for a number of reasons; however, the data values are still for the 15 minute interval.
    "minimum_speed_detection_setting", -- The lowest speed setting for the DFS Unit used to determine the speed ranges for each Bin.
    "site_id", -- A unique ID assigned to the location for proper/accurate identification.
    "maximum_speed_for_bin_number", -- The fastest detected speed travelled that corresponds to the Bin Number.  Vehicles can travel less than or equal to this speed for it to be recorded for the Bin.  NOTE: For Bin 10, the maximum detectable speed is approximately 225 KPH.
    "row_id", -- System generated ID to eliminate the possibility of duplicate data.
    "bin_number", -- A value between 1 and 10, representing the data bin for which the vehicle count and the speed range is applicable.  Bin 1 records the number of vehicles that were detected to travel in the slowest speed range and Bin 10 would be for the fastest speed range.
    "speed_range_for_bin", -- A calculated value based on (Maximum Speed Detection Setting and Minimum Speed Detection Setting).    NOTE:  - For Bin 1, the minimum detectable speed is approximately 6 KPH. - For Bin 10, the maximum detectable speed is approximately 225 KPH.
    "speed_limit", -- The Speed Limit setting for the DFS unit.  Note: This may not be the enforceable speed for the roadway.
    "bin_over_speed_limit_flag", -- A flag value that indicates the following: 0 - if the both the Minimum Speed and Maximum Speed for the Bin are below the Speed Limit 1 - if the Speed Limit is between the Minimum Speed and Maximum Speed for the Bin 2 - if the value of both the Minimum Speed and Maximum Speed for the Bin are greater than the Speed Limit
    "maximum_speed_detection_setting", -- The fastest speed setting for the DFS Unit used to determine the speed ranges for each Bin.
    "direction", -- The direction of travel of vehicles that are being detected by the DFS unit.
    "speed_unit_of_measure" -- The Speed Unit of Measure.  Note: The usual setting is KPH but could also be MPH.
FROM
    "edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h:latest"."driver_feedback_sign_dfs007"
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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h 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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h: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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h

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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h:latest

This will download all the objects for the latest tag of edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h 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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h: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 edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h: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, edmonton-ca/driver-feedback-sign-dfs007-8c4k-569h is just another Postgres schema.

Related Documentation:

Loading...