edmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq
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 driver_feedback_sign_dfs009 table in this repository, by referencing it like:

"edmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq:latest"."driver_feedback_sign_dfs009"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "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.
    "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.
    "row_id", -- System generated ID to eliminate the possibility of duplicate data.
    "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.
    "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_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.
    "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
    "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.
    "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_detection_setting", -- The lowest speed setting for the DFS Unit used to determine the speed ranges for each Bin.
    "speed_limit", -- The Speed Limit setting for the DFS unit.  Note: This may not be the enforceable speed for the roadway.
    "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.
    "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.
    "maximum_speed_detection_setting", -- The fastest 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.
FROM
    "edmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq:latest"."driver_feedback_sign_dfs009"
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-dfs009-3ub7-7vvq with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.edmonton.ca. When you queryedmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq: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.edmonton.ca, 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 \
  "edmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq" \
  --handler-options '{
    "domain": "data.edmonton.ca",
    "tables": {
        "driver_feedback_sign_dfs009": "3ub7-7vvq"
    }
}'

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, edmonton-ca/driver-feedback-sign-dfs009-3ub7-7vvq is just another Postgres schema.