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_est", -- The estimated latitude along the roadway where the work zone area begins.
    "startdatetime_est", -- The planned time and date when a work zone starts.
    "totallanes", -- The total number of lanes associated with the road segment designated by the BeginLocation and EndLocation.
    "startdatetime_cancelled", -- Cancellation of a planned start time and date assocaited with a work zone.
    "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.
    "startdatetime", -- The estimated or verified time and date when a work zone starts.
    "startdatetime_ver", -- A verified time and date when the work zone was actually installed.
    "workerspresent", -- A flag indicating that there are workers present in the work zone.
    "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_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.
    "beginlocation", -- The estimated or verified coordinates along the roadway where the work zone area begins.
    "endlocation_longitude_ver", -- A verified longitude along the roadway where the work zone area ends.
    "timestampeventcreation", -- The time and date when the activity or event was created.
    "beginlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area begins.
    "beginlocation_crossstreet", -- The cross street along the roadway where the work zone area begins. Required when Road Classification is arterial
    "beginlocation_longitude_est", -- The estimated longitude along the roadway where the work zone area begins.
    "enddatetime_est", -- The planned time and date when a work zone ends.
    "endlocation_latitude_est", -- The latitude along a roadway where the work zone area ends and the traffic returns to normal.
    "endlocation_longitude_est", -- The longitude along a roadway where the work zone area ends and the traffic returns to normal.
    "beginlocation_milepost_ver", -- An accurately linear distance measured against a milepost marker along a roadway where the work zone begins.
    "reducedspdposted", -- The reduced speed limit posted in the work zone
    "header_versionno", -- The WZDx version number that was used to create the file.
    "beginlocation_roadname", -- The name of the road on which the work zone applies which is known by the public.
    "subidentifier", -- A unique identifier issued by data feed provider that provides additional references to project or activity.
    "beginlocation_latitude_ver", -- A verified latitude along the roadway where the work zone area begins.
    "beginlocation_milepost_est", -- The estimated 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.
    "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.
    "identifier", -- A unique identifier issued by the data feed provider to identify the work zone project or activity
    "header_timestampupdate", -- An element that designates the data and time the data feed was last updated.
    "closedshoulders", -- An enumerated type identifying the shoulder lanes that are closed. Allowed values: outside, inside, both, none, unknown.
    "description", -- Short free text description of work zone.
    "enddatetime_ver", -- A verified time and date when the work zone was actually ended.
    "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_latitude_ver", -- A verified latitude along the roadway where the work zone area ends.
    "issuingorganization", -- The organization issuing the data feed
    "header_metadataurl", -- A link to the metadata file (WZ-metadata.txt). See Section 2.6 for a description of the file.
    "beginlocation_latitude", -- The estimated or verified latitude along the roadway where the work zone area begins.
    "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.
    "endlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area ends.
    "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.
    "endlocation_milepost_ver", -- An accurately linear distance measured against a milepost marker along a roadway where the work zone begins.
    "beginlocation_longitude_ver", -- A verified longitude along the roadway where the work zone area begins.
    "enddatetime", -- The estimated or verified time and date when a work zone ends.
    "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.
    "startdatetime_timeconfidencelevel" -- A confidence leve (in percentage) of when the work zone activities will actually start.
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.