datahub-transportation-gov/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx
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 2022_ntd_annual_data_operating_expenses_by_type table in this repository, by referencing it like:

"datahub-transportation-gov/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx:latest"."2022_ntd_annual_data_operating_expenses_by_type"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "tires_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "casualty_and_liability_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "taxes", -- Tax expenses are the charges and assessments levied against the transit agency by federal, state and local governments. 
    "separate_report_amount", -- Payments or accruals to sellers or providers of service, including fare revenues retained by the seller, in the case when the rest of the data are reported by a different NTD reporting agency. These expenses are also included in the other agency's report, so they are excluded from the Total column to avoid double counting.
    "separate_report_amount_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "casualty_and_liability", -- Casualty and liability costs are expenses related to loss protection and losses incurred by the transit agency. 
    "fringe_benefits_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "miscellaneous_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "operator_paid_absences_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "operators_wages", -- Operators’ salaries and wages include the cost of labor, excluding paid absences and fringe benefits, for the transit agency's employees who are classified as revenue vehicle operators or crewmembers. 
    "other_materials_supplies_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "other_paid_absences_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "other_salaries_wages_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "purchased_transportation_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "reduced_reporter_expenses_1", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "services_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "taxes_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "tires", -- This object class includes the cost of tires and tubes, whether they are rented, leased or purchased. 
    "total_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "total", -- Total of the operating expenses reported in previous columns. Does not include Purchased Transportation Reported Separately.
    "reduced_reporter_expenses", -- Operating expenses incurred by agencies that do not report operating expenses in specific categories because they have reduced reporting requirements.
    "miscellaneous", -- This object class includes expenses that cannot be attributed to any of the other expense object classes. 
    "purchased_transportation", -- Purchased Transportation (PT) expenses include the payments or accruals to sellers or providers of service, including fare revenues retained by the seller. 
    "other_materials_supplies", -- The cost of materials and supplies other than fuel, lubricants, or tires.
    "fuel_and_lube_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "fuel_and_lube", -- This object class includes fuel used to propel revenue and non-revenue vehicles and lubricants such as motor oil, transmission fluid, and grease. 
    "services", -- Services are the labor and other work provided by outside organizations for fees and related expenses. Outside organizations may be private companies or public entities. 
    "fringe_benefits", -- Fringe benefits are the expenses for employment benefits that an employee receives in addition to his or her base salaries and wages. Fringe benefits include payments associated with the employee's labor that do not arise from the performance of work, but still arise from the employment relationship. 
    "other_paid_absences", -- Paid absences for employees of the transit agency who are not classified as revenue vehicle operators or crewmembers (e.g., maintenance workers, administrative staff, and transit managers).
    "operator_paid_absences", -- Paid absences for the transit agency's employees who are classified as revenue vehicle operators or crewmembers. 
    "other_salaries_wages", -- This object class includes the cost of labor, excluding paid absences and fringe benefits, of employees of the transit agency who are not classified as revenue vehicle operators or crewmembers (e.g., maintenance workers, administrative staff, and transit managers).
    "mode_voms", -- The number of revenue vehicles operated by the given mode and type of service to meet the annual maximum service requirement. This is the revenue vehicle count during the peak season of the year; on the week and day that maximum service is provided. Vehicles operated in maximum service (VOMS) exclude atypical days and one-time special events.
    "agency_voms", -- The number of revenue vehicles operated across the whole agency to meet the annual maximum service requirement. This is the revenue vehicle count during the peak season of the year; on the week and day that maximum service is provided. Vehicles operated in maximum service (VOMS) exclude atypical days and one-time special events.
    "primary_uza_population", -- The population of the urbanized area primarily served by the agency.
    "uza_name", -- The name of the agency's Urbanized Area.
    "uace_code", -- UACE Code remains consistent across census years.
    "reporter_type", -- The type of NTD report that the agency completed this year.
    "organization_type", -- Description of the agency's legal entity.
    "ntd_id", -- A five-digit identifying number for each agency used in the current NTD system.
    "state", -- The state in which the agency is headquartered.
    "agency", -- The transit agency's name.
    "mode_name", -- A system for carrying transit passengers described by specific right-of-way (ROW), technology and operational features.
    "utilities_questionable", -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
    "utilities", -- This object class includes expenses for electricity, gas, water, telephone, heating oil, fuel for backup generators, and internet. 
    "type_of_service", -- Describes how public transportation services are provided by the transit agency: directly operated (DO) or purchased transportation (PT) services.
    "city", -- The city in which the agency is headquartered.
    "report_year", -- The year for which the data was reported.
    "mode", -- A system for carrying transit passengers described by specific right-of-way (ROW), technology and operational features.
    "operators_wages_questionable" -- FTA marks a data point as Questionable when there is reason to believe it is incorrect, but the reporting agency has been unable to correct the data or offer an explanation for its anomalous appearance.
FROM
    "datahub-transportation-gov/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx:latest"."2022_ntd_annual_data_operating_expenses_by_type"
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/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx 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/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx: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/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx" \
  --handler-options '{
    "domain": "datahub.transportation.gov",
    "tables": {
        "2022_ntd_annual_data_operating_expenses_by_type": "j5uj-anzx"
    }
}'

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/2022-ntd-annual-data-operating-expenses-by-type-j5uj-anzx is just another Postgres schema.