datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr
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 enhancing_microsimulation_models_for_improved_work table in this repository, by referencing it like:

"datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr:latest"."enhancing_microsimulation_models_for_improved_work"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "speed_limit", -- The speed limit of the section of route on which the driver is traveling, in miles per hour.
    "current_lane", -- Current travel lane, numbered from 1 (leftmost lane) to num_lanes (rightmost lane).
    "follower_radar", -- Records the sensor that was used to measure information about the following vehicle. Valid values are: 0: The following vehicle was detected by the front radar. 1: The following vehicle was detected by the rear radar. 10: The IRV is the following vehicle.
    "leader_veh_type", -- A description of the type of the lead vehicle. Valid values are: PC: passenger car. HV: heavy vehicle. B: bus. M: motorcycle.
    "start_time", -- The start time of the car-following instance, measured since the start of the data collection run, in HH:MM:SS.sss format.
    "end_time", -- The end time of the car-following instance, measured since the start of the data collection run, in HH:MM:SS.sss format.
    "road_type", -- A description of the road the vehicle is traveling on. Valid values are: HW: Highway. A U.S. or State route, which is not an interstate.  IS: Interstate. A numbered Interstate highway with two or more lanes. In this dataset, this is I-91. AW: Advanced Warning. The vehicle is traveling on the freeway towards the work zone.  The vehicle has already passed advanced warning signage for the work zone (ex. "Work Zone in 1 mile") TZ: Taper Zone. The vehicle is entering and/or traversing the freeway work zone's taper zone WZ1: Work Zone with Lane Closure. The vehicle is traversing the buffer zone and/or the work zone, for a freeway work zone with lane closure. WZ2: Work Zone without Lane Closure. The vehicle is traversing the buffer zone and/or the work zone, for a freeway work zone without lane closure. Because some work zones traversed along this route were collected on arterials as well as freeways, “HW” or “IS” are appended to the end of codes AW, TZ, WZ1, WZ2 to indicate the type of road being worked on.
    "wz_markers", -- This field indicates the type of physical delineators used in the work zone. Valid values include: C: Cones. D: Drums or Barrels. JB: Jersey Barriers. Multiple values can be present in this field (comma-separated).
    "congestion", -- Records the traffic conditions. Valid values are: C: Congested. Because of surrounding traffic, the travel speed of the subject vehicle is below 35 mph (or 15.6 m/s) in a non-work zone, or below 25 mph (or 11.1 m/s) in a work zone. U: Uncongested. Traffic conditions allow the subject vehicle to travel 35 mph (or 15.6 m/s) or faster in a non-work zone, or 25 mph (or 11.1 m/s) or faster in a work zone.
    "global_instance_id", -- Unique identifier of each instance record (primary key). Defined by (run_id*1000 + run_instance_id)
    "wz_status", -- Indicates if the work zone is passive or active. Valid values include: P: no workers present; A: active work zone, workers present.
    "run_id", -- ID of the data collection run (foreign key to runs table)
    "run_instance_id", -- An ID was assigned by the data processing team to each car-following instance recorded during each driver’s run. Note that this count resets for each driver.
    "parent_instance_id", -- During some car-following instances, the road characteristics (road_type, congestion, or speed_limit) changed while the same leader/follower pair continued to follow each other. These instances are represented by multiple records in the table, which have the same parent_instance_id but different run_instance_id values.
    "num_lanes", -- Number of travel lanes in the direction of travel.
    "leader_radar", -- Records the sensor that was used to measure information about the lead vehicle. Valid values are: 0: The lead vehicle was detected by the front radar. 1: The lead vehicle was detected by the rear radar. 10: The IRV is the lead vehicle.
    "follower_veh_type", -- A description of the type of the following vehicle. Valid values are: PC: passenger car. HV: heavy vehicle. B: bus. M: motorcycle.
    "signage", -- Temporary signage in the advanced warning zone, or message board signage in the taper zone. Valid values include: W20-1, W20-3, W4-2, W20-4, W8-1: see MUTCD sign designations for description. FA: flashing arrow on message board. Multiple values can be present in this field (comma-separated).
    "rural_urban", -- Whether the road is urban or rural. Valid values are: U: Urban. Instances within 2 miles of an on-ramp or off-ramp to Springfield, MA are considered urban. R: Rural. Other instances are considered rural.
    "wz_enforcement" -- Whether law enforcement vehicles or officers were present at the time of data capture. Valid values include: Y: yes; N: no.
FROM
    "datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr:latest"."enhancing_microsimulation_models_for_improved_work"
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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr 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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr: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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr

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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr:latest

This will download all the objects for the latest tag of datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr 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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr: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 datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr: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, datahub-transportation-gov/enhancing-microsimulation-models-for-improved-work-74ug-57tr is just another Postgres schema.

Related Documentation:

Loading...