datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5
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 maricopa_county_regional_work_zone_data_exchange table in this repository, by referencing it like:

"datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5:latest"."maricopa_county_regional_work_zone_data_exchange"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "data_source_contact_email", -- The email address of the individual or group responsible for the data source.
    "road_number", -- The road number designated by a jurisdiction such as a county, state or interstate.
    "direction", -- The digitization direction of the road that is impacted by the event. This value is based on the standard naming for US roadways and indicates the direction the traffic flow regardless of the real heading angle.
    "beginning_accuracy", -- Indicates how the beginning coordinate was defined.
    "road_event_feed_info_contact", -- The name of the individual or group responsible for the data feed.
    "end_date", -- The UTC time and date when the event ends.
    "ending_milepost", -- The linear distance measured against a milepost marker along a roadway where the event ends.
    "beginning_cross_street", -- Name or number of the nearest cross street along the roadway where the event begins.
    "stroke_opacity", -- The opacity of the GeoJSON stroke.
    "relationship_children", -- Arrays of IDs indicating entities that are part of the road event with this relationship, such as a detour or piece of equipment.
    "data_source_lrs_url", -- A URL where additional information on the LRS information and transformation information is stored.
    "road_event_feed_info_update_1", -- The frequency in seconds at which the data feed is updated.
    "ending_cross_street", -- Name or number of the nearest cross street along the roadway where the event ends.
    "start_date", -- The UTC time and date when the event begins.
    "data_source_id", -- Unique identifier for the organization providing work zone data.
    "data_source_organization", -- The name of the organization for the authoritative source of the work zone data.
    "event_type", -- The type/classification of road event.
    "restrictions", -- One or more road restrictions applying to the work zone road segment associated with the work zone delimited by semicolons.
    "feed_update_date", -- The UTC date and time when the data feed was last updated.
    "update_date", -- The UTC time and date when the activity or event was updated.
    "road_event_feed_info_version", -- The WZDx specification version used to create the data feed in major.minor format.
    "description", -- Short free text description of road event.
    "creation_date", -- The UTC time and date when the activity or event was created.
    "road_event_id", -- A unique identifier issued by the data feed provider to identify the work zone project or activity.
    "types_of_work", -- Stringified array of JSON objects indicating the type of work being done in a road event, if applicable (e.g. typical work zones), as well as noting if the type of work will result in an architectural change to the roadway. Each JSON object can contain the following fields: “type_of_work_id” - ID identifying the types_of_work record; “type_name” - a high-level text description of the type of work being done; “is_architectural_change” - an optional boolean flag indicating whether the type of work will result in an architectural change to the roadway.
    "stroke", -- The color of the GeoJSON stroke.
    "relationship_parents", -- Array of IDs indicating entities that the road event with this relationship is a part of, such as a work zone project or phase.
    "road_event_feed_info_contact_1", -- The email address of the individual or group responsible for the data feed.
    "road_name", -- Publicly known name of the road on which the event occurs.
    "beginning_milepost", -- The linear distance measured against a milepost marker along a roadway where the event begins.
    "ending_accuracy", -- Indicates how the ending coordinate was defined.
    "end_date_accuracy", -- A measure of how accurate the end Date Time is.
    "data_source_lrs_type", -- Describes the type of linear referencing system (LRS) used for the milepost measurements.
    "total_num_lanes", -- The total number of lanes associated with the road segment designated by the event geometry.
    "data_source_location_method", -- The typical method used to locate the beginning and end of a work zone impact area.
    "lanes", -- Stringified array of JSON objects identifying and describing individual lanes within a road event. Each lane JSON object can contain the following fields: “order” - The position of a lane in sequence on the roadway. This value is used as an index to indicate the order of all WZDx lanes provided for a road event; “type” - an indication of the type of lane or shoulder.); “status” - status of the lane for the traveling public; “lane_number” - the number assigned to the lane to help identify its position. Flexible, but usually used for regular, driveable lanes; “restrictions” - an array of lane_restriction JSON objects. Each lane_restriction JSON object contain the following fields: “restriction_type” - the type of restriction being enforced; “restriction_value” - the measure of the restriction type; “restriction_units” - units of measure for the restriction value. The “restriction_type” field of the lane_restriction JSON object is required. The “order”, “type”, and “status” fields of the lane JSON object are required.
    "data_source_contact_name", -- The name of the individual or group responsible for the work zone data source.
    "road_event_feed_info_publisher", -- The organization responsible for publishing the feed.
    "data_source_update_date", -- The UTC date and time when the data source was last updated.
    "relationship_next", -- Array of IDs indicating the next (can be multiple) road event in a sequence by road_event_id.
    "data_source_update_frequency", -- The frequency in seconds at which the data source is updated.
    "data_source_location_verify", -- The method used to verify the accuracy of the location information.
    "relationship_first", -- Array of IDs indicating the first (can be multiple) road event in a sequence of road events by road_event_id.
    "stroke_width", -- The width of the GeoJSON stroke.
    "geometry_multipoint", -- A coordinate pair or an array of coordinates. In either case, the first coordinate is the beginning point and the last coordinate is the ending point of the road event.
    "geometry_linestring", -- A coordinate pair or an array of coordinates. In either case, the first coordinate is the beginning point and the last coordinate is the ending point of the road event.
    "reduced_speed_limit", -- The reduced speed limit posted within the event space.
    "workers_present", -- A flag indicating that there are workers present in the event space.
    "vehicle_impact", -- The impact to vehicular lanes along a single road in a single direction.
    "event_status", -- The status of the event.
    "start_date_accuracy" -- A measure of how accurate the start Date Time is.
FROM
    "datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5:latest"."maricopa_county_regional_work_zone_data_exchange"
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/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at datahub.transportation.gov. When you querydatahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5: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 datahub.transportation.gov, 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 \
  "datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5" \
  --handler-options '{
    "domain": "datahub.transportation.gov",
    "tables": {
        "maricopa_county_regional_work_zone_data_exchange": "9jif-8qi5"
    }
}'

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, datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-9jif-8qi5 is just another Postgres schema.