datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-wd94-wugt
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-wd94-wugt:latest"."maricopa_county_regional_work_zone_data_exchange"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "beginlocation_latitude_ver", -- A verified latitude along the roadway where the work zone area begins.
    "subidentifier", -- A unique identifier issued by data feed provider that provides additional references to project or activity.
    "endlocation_milepost_est", -- The measured linear distance along a roadway where the work zone begins.
    "wz_status", -- The status of the work zone. Allowed values: Planned, Pending, Active, Cancelled, Completed.
    "identifier", -- A unique identifier issued by the data feed provider to identify the work zone project or activity
    "startdatetime_ver", -- A verified time and date when the work zone was actually installed.
    "enddatetime_ver", -- A verified time and date when the work zone was actually ended.
    "header_timestampupdate", -- An element that designates the data and time the data feed was last updated.
    "beginlocation", -- The estimated or verified coordinates along the roadway where the work zone area begins.
    "timestampeventcreation", -- The time and date when the activity or event was created.
    "closedlanes", -- The laneType that is closed due to the work zone on the road segment designated by the Begin Location and EndLocation. Allowed values: all, left-lane, right-lane, left-2-lanes, left-3-lanes, right-2-lanes, right-3-lanes, center, middle-lane, right-turning-lane, left-turning-lane, right-exit-lane, left-exit-lane, right-merging-lane, left-merging-lane, right-exit-ramp, right-second-exit-ramp, right-entrance-ramp, right-second-entrance-ramp, left-exit-ramp, left-second-exit-ramp, left-entrance-ramp, left-second-entrance-ramp, sidewalk, bike-lane, none, unknown, alternate-flow-lane, shift-left, shift-right.
    "endlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area ends.
    "startdatetime", -- The estimated or verified time and date when a work zone starts.
    "beginlocation_longitude_ver", -- A verified longitude along the roadway where the work zone area begins.
    "enddatetime_cancelled", -- Cancellation of a planned end time and date assocaited with a work zone.
    "timestampeventupdate", -- The time and date when the activity or event was updated.
    "beginlocation_latitude", -- The estimated or verified latitude along the roadway where the work zone area begins.
    "startdatetime_timeconfidencelevel", -- A confidence leve (in percentage) of when the work zone activities will actually start.
    "startdatetime_est", -- The planned time and date when a work zone starts.
    "roadrestrictions", -- One or more roadRestriction flags indicating restrictions applied to the work zone road segment associated with the work zone bounded by the begin / end locations. Allowed values: no-trucks, travel-peak-hours-only, hov-3, hov-2, no-parking, bike-lane, ramp, towing-prohibited, permitted-oversize-loads-prohibited, reduced-width, reduced-height, reduced-length, reduced-weight, axle-load-limit, gross-weight-limit.
    "endlocation_milepost_ver", -- An accurately linear distance measured against a milepost marker along a roadway where the work zone begins.
    "enddatetime_timeconfidencelevel", -- A confidence leve (in percentage) of when the work zone activities will actually start.
    "startdatetime_cancelled", -- Cancellation of a planned start time and date assocaited with a work zone.
    "beginlocation_longitude_est", -- The estimated longitude along the roadway where the work zone area begins.
    "totallanes", -- The total number of lanes associated with the road segment designated by the BeginLocation and EndLocation.
    "beginlocation_milepost_ver", -- An accurately linear distance measured against a milepost marker along a roadway where the work zone begins.
    "beginlocation_latitude_est", -- The estimated latitude along the roadway where the work zone area begins.
    "header_versionno", -- The WZDx version number that was used to create the file.
    "beginlocation_milepost_est", -- The estimated linear distance measured against a milepost marker along a roadway where the work zone begins.
    "beginlocation_roaddirection", -- The designated direction of the roadName that is impacted by the work zone activity. Allowed values: northbound, eastbound, southbound, westbound.
    "beginlocation_roadnum", -- The road number designated by a jurisdiction such as a county, state or interstate.
    "workerspresent", -- A flag indicating that there are workers present in the work zone.
    "header_metadataurl", -- A link to the metadata file (WZ-metadata.txt). See Section 2.6 for a description of the file.
    "endlocation", -- The estimated or verified coordinates along the roadway where the work zone area ends.
    "endlocation_latitude", -- The estimated or verified latitude along the roadway where the work zone area ends.
    "enddatetime", -- The estimated or verified time and date when a work zone ends.
    "openlanes", -- The laneType that is opened on the road segment designated by the work zone BeginLocation. Allowed values: all, left-lane, right-lane, left-2-lanes, left-3-lanes, right-2-lanes, right-3-lanes, center, middle-lane, right-turning-lane, left-turning-lane, right-exit-lane, left-exit-lane, right-merging-lane, left-merging-lane, right-exit-ramp, right-second-exit-ramp, right-entrance-ramp, right-second-entrance-ramp, left-exit-ramp, left-second-exit-ramp, left-entrance-ramp, left-second-entrance-ramp, sidewalk, bike-lane, none, unknown, alternate-flow-lane, shift-left, shift-right.
    "issuingorganization", -- The organization issuing the data feed
    "endlocation_latitude_ver", -- A verified latitude along the roadway where the work zone area ends.
    "description", -- Short free text description of work zone.
    "closedshoulders", -- An enumerated type identifying the shoulder lanes that are closed. Allowed values: outside, inside, both, none, unknown.
    "beginlocation_roadname", -- The name of the road on which the work zone applies which is known by the public.
    "reducedspdposted", -- The reduced speed limit posted in the work zone
    "endlocation_longitude_est", -- The longitude along a roadway where the work zone area ends and the traffic returns to normal.
    "endlocation_latitude_est", -- The latitude along a roadway where the work zone area ends and the traffic returns to normal.
    "enddatetime_est", -- The planned time and date when a work zone ends.
    "beginlocation_crossstreet", -- The cross street along the roadway where the work zone area begins. Required when Road Classification is arterial
    "beginlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area begins.
    "endlocation_crossstreet", -- The cross street along a roadway where the work zone area ends and the traffic returns to normal. Required when Road Classification is arterial
    "endlocation_longitude_ver" -- A verified longitude along the roadway where the work zone area ends.
FROM
    "datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-wd94-wugt: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-wd94-wugt 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-wd94-wugt: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-wd94-wugt" \
  --handler-options '{
    "domain": "datahub.transportation.gov",
    "tables": {
        "maricopa_county_regional_work_zone_data_exchange": "wd94-wugt"
    }
}'

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-wd94-wugt is just another Postgres schema.