datahub-transportation-gov/next-generation-simulation-ngsim-vehicle-8ect-6jqj
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 next_generation_simulation_ngsim_vehicle table in this repository, by referencing it like:

"datahub-transportation-gov/next-generation-simulation-ngsim-vehicle-8ect-6jqj:latest"."next_generation_simulation_ngsim_vehicle"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "o_zone", -- Origin zones of the vehicles, i.e., the place where the vehicles enter the tracking system. There are 11 origins in the study area, numbered from 101 through 111. Please refer to the data analysis report for more detailed information.
    "d_zone", -- Destination zones of the vehicles, i.e., the place where the vehicles exit the tracking system. There are 10 destinations in the study area, numbered from 201 through 211. Origin 102 is a one-way off-ramp; hence there is no associated destination number 202. Please refer to the data analysis report for more detailed information.
    "direction", --  Moving direction of the vehicle. 1 - east-bound (EB), 2 - north-bound (NB), 3 - west-bound (WB), 4 - south-bound (SB). 
    "following", -- Vehicle ID of the vehicle following the subject vehicle in the same lane. A value of '0' represents no following vehicle - occurs at the beginning of the study section and onramp due to the fact that only complete trajectories were recorded by this data collection effort (vehicle that did not traverse the downstream boundaries of the section by the end of the study period were not recorded).
    "lane_id", -- Current lane position of vehicle. Lane 1 is farthest left lane; lane 5 is farthest right lane. Lane 6 is the auxiliary lane between Ventura Boulevard on-ramp and the Cahuenga Boulevard off-ramp. Lane 7 is the on-ramp at Ventura Boulevard, and Lane 8 is the off-ramp at Cahuenga Boulevard.
    "int_id", -- Intersection in which the vehicle is traveling. Intersections are numbered from 1 to 4, with intersection 1 at the southernmost, and intersection 4 at the northernmost section of the study area. Value of “0” means that the vehicle was not in the immediate vicinity of an intersection and that the vehicle instead identifies with a section of Lankershim Boulevard (Section_ID, below). Please refer to the data analysis report for more detailed information. 
    "time_headway", -- Time Headway in seconds. Time Headway provides the time to travel from the front-center of a vehicle (at the speed of the vehicle) to the front-center of the preceding vehicle. A headway value of 99
    "movement", -- Movement of the vehicle. 1 - through (TH), 2 - left-turn (LT), 3 - right-turn (RT).
    "frame_id", --  Frame Identification number (ascending by start time)
    "local_x", -- Lateral (X) coordinate of the front center of the vehicle in feet with respect to the left-most edge of the section in the direction of travel.
    "global_time", -- Elapsed time in milliseconds since Jan 1, 1970.
    "total_frames", --  Total number of frames in which the vehicle appears in this data set
    "vehicle_id", -- Vehicle identification number (ascending by time of entry into section). REPEATS ARE NOT ASSOCIATED. 
    "preceding", -- Vehicle ID of the lead vehicle in the same lane. A value of '0' represents no preceding vehicle - occurs at the end of the study section and off-ramp due to the fact that only complete trajectories were recorded by this data collection effort (vehicles already in the section at the start of the study period were not recorded).
    "v_class", -- Vehicle type: 1 - motorcycle, 2 - auto, 3 - truck 
    "section_id", -- Section in which the vehicle is traveling. Lankershim Blvd is divided into five sections (south of intersection 1; between intersections 1 and 2, 2 and 3, 3 and 4; and north of intersection 4). Value of “0” means that the vehicle does not identify with a section of Lankershim Boulevard and that the vehicle was in the immediate vicinity of an intersection (Int_ID above). Please refer to the data analysis report for more detailed information
    "location", -- Name of street or freeway 
    "space_headway", -- Space Headway in feet. Spacing provides the distance between the frontcenter of a vehicle to the front-center of the preceding vehicle.
    "local_y", -- Longitudinal (Y) coordinate of the front center of the vehicle in feet with respect to the entry edge of the section in the direction of travel.
    "global_x", -- X Coordinate of the front center of the vehicle in feet based on CA State Plane III in NAD83. Attribute Domain Val
    "v_length", -- Length of vehicle in feet
    "global_y", -- Y Coordinate of the front center of the vehicle in feet based on CA State Plane III in NAD83.
    "v_width", -- Width of vehicle in feet
    "v_vel", -- Instantaneous velocity of vehicle in feet/second.
    "v_acc" -- Instantaneous acceleration of vehicle in feet/second square.
FROM
    "datahub-transportation-gov/next-generation-simulation-ngsim-vehicle-8ect-6jqj:latest"."next_generation_simulation_ngsim_vehicle"
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/next-generation-simulation-ngsim-vehicle-8ect-6jqj 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/next-generation-simulation-ngsim-vehicle-8ect-6jqj: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/next-generation-simulation-ngsim-vehicle-8ect-6jqj

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/next-generation-simulation-ngsim-vehicle-8ect-6jqj:latest

This will download all the objects for the latest tag of datahub-transportation-gov/next-generation-simulation-ngsim-vehicle-8ect-6jqj 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/next-generation-simulation-ngsim-vehicle-8ect-6jqj: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/next-generation-simulation-ngsim-vehicle-8ect-6jqj: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/next-generation-simulation-ngsim-vehicle-8ect-6jqj is just another Postgres schema.

Related Documentation:

Loading...