datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-wd94-wugt
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 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
    "subidentifier", -- A unique identifier issued by data feed provider that provides additional references to project or activity.
    "description", -- Short free text description of work zone.
    "endlocation_milepost_est", -- The measured linear distance along a roadway where the work zone 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
    "closedshoulders", -- An enumerated type identifying the shoulder lanes that are closed. Allowed values: outside, inside, both, none, unknown.
    "workerspresent", -- A flag indicating that there are workers present in the work zone.
    "beginlocation_roadname", -- The name of the road on which the work zone applies which is known by the public.
    "beginlocation_roadnum", -- The road number designated by a jurisdiction such as a county, state or interstate.
    "reducedspdposted", -- The reduced speed limit posted in the work zone
    "beginlocation_roaddirection", -- The designated direction of the roadName that is impacted by the work zone activity. Allowed values: northbound, eastbound, southbound, westbound.
    "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.
    "beginlocation_milepost_est", -- The estimated linear distance measured against a milepost marker along a roadway where the work zone begins.
    "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.
    "enddatetime_est", -- The planned time and date when a work zone ends.
    "header_versionno", -- The WZDx version number that was used to create the file.
    "endlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area ends.
    "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.
    "beginlocation_crossstreet", -- The cross street along the roadway where the work zone area begins. Required when Road Classification is arterial
    "beginlocation_latitude_ver", -- A verified latitude along the roadway where the work zone area begins.
    "timestampeventcreation", -- The time and date when the activity or event was created.
    "beginlocation", -- The estimated or verified coordinates along the roadway where the work zone area begins.
    "wz_status", -- The status of the work zone. Allowed values: Planned, Pending, Active, Cancelled, Completed.
    "totallanes", -- The total number of lanes associated with the road segment designated by the BeginLocation and EndLocation.
    "beginlocation_latitude", -- The estimated or verified latitude along the roadway where the work zone area begins.
    "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.
    "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.
    "beginlocation_milepost_ver", -- An accurately linear distance measured against a milepost marker along a roadway where the work zone begins.
    "startdatetime", -- The estimated or verified time and date when a work zone starts.
    "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_latitude_est", -- The estimated latitude along the roadway where the work zone area begins.
    "header_metadataurl", -- A link to the metadata file (WZ-metadata.txt). See Section 2.6 for a description of the file.
    "beginlocation_longitude", -- The estimated or verified longitude along the roadway where the work zone area begins.
    "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_longitude_ver", -- A verified longitude along the roadway where the work zone area ends.
    "endlocation_latitude_ver" -- A verified latitude 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.

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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt: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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt

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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt:latest

This will download all the objects for the latest tag of datahub-transportation-gov/maricopa-county-regional-work-zone-data-exchange-wd94-wugt 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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt: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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt: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/maricopa-county-regional-work-zone-data-exchange-wd94-wugt is just another Postgres schema.

Related Documentation:

Loading...