datahub-transportation-gov/2022-ntd-annual-data-fuel-and-energy-8ehq-7his
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 2022_ntd_annual_data_fuel_and_energy table in this repository, by referencing it like:

"datahub-transportation-gov/2022-ntd-annual-data-fuel-and-energy-8ehq-7his:latest"."2022_ntd_annual_data_fuel_and_energy"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "bio_diesel_gal", -- Gallons of biodiesel (diesel fuel derived from biological, non-petroleum sources) used.
    "hydrogen_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.
    "other_fuel_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.
    "electric_propulsion_kwh", -- Kilowatt-hours of electricity used to propel vehicles by directly providing power via a third rail or overhead catenary.
    "other_fuel_gal_gal_equivalent_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.
    "electric_battery_kwh", -- Kilowatt-hours of electricity used to charge a vehicle's battery, which then propels the motor.
    "diesel", -- Agencies report use of conventional diesel and biodiesel separately, but do not report the miles traveled by conventional diesel- and biodiesel-fueled vehicles separately. This table reflects that reporting structure. Gallons of conventional diesel and gallons of biodiesel used are added together to calculate miles traveled for diesel vehicles.
    "gasoline", -- Miles traveled by gasoline-powered vehicles.
    "other_fuel_gal_gal_equivalent", -- Gallons of other fuels used. Includes bunker fuel, recycled cooking oil, ethanol, hydrogen, kerosene, liquefied natural gas, and any other fuel not listed.
    "liquefied_petroleum_gas_mpg_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.
    "liquefied_petroleum_gas_mpg", -- Miles per gallon for liquefied petroleum gas-powered vehicles.
    "liquefied_petroleum_gas_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.
    "liquefied_petroleum_gas", -- Miles traveled by liquefied petroleum gas-powered vehicles.
    "gasoline_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.
    "compressed_natural_gas", -- Miles traveled by compressed natural gas-powered vehicles.
    "gasoline_mpg_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.
    "compressed_natural_gas_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.
    "hydrogen", -- Miles traveled by hydrogen-powered vehicles.
    "other_fuel", -- Miles traveled by vehicles fueled by another energy source.
    "electric_propulsion", -- Miles traveled by electric propulsion-powered vehicles.
    "electric_battery", -- Miles traveled by electric battery-powered vehicles.
    "diesel_mpg", -- Agencies report use of conventional diesel and biodiesel separately, but do not report the miles traveled by conventional diesel- and biodiesel-fueled vehicles separately. This table reflects that reporting structure. Gallons of conventional diesel and gallons of biodiesel used are added together to calculate miles per gallon for diesel vehicles.
    "gasoline_mpg", -- Miles per gallon for gasoline-powered vehicles.
    "electric_propulsion_mi_kwh_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.
    "electric_propulsion_mi_kwh", -- Miles per kilowatt for electric propulsion-powered vehicles.
    "electric_propulsion_kwh_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.
    "diesel_mpg_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.
    "compressed_natural_gas_mpg_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_fuel_mpg", -- Miles per gallon for vehicles powered by another energy source.
    "bio_diesel_gal_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.
    "agency", -- The transit agency's name.
    "electric_battery_mi_kwh", -- Miles per kilowatt for electric battery-powered vehicles.
    "compressed_natural_gas_gal_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.
    "compressed_natural_gas_gal", -- Gallons of compressed natural gas used.
    "liquefied_petroleum_gas_gal_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.
    "liquefied_petroleum_gas_gal", -- Gallons of liquefied petroleum gas (propane) used.
    "gasoline_gal_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.
    "gasoline_gal", -- Gallons of gasoline used.
    "diesel_gal_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.
    "diesel_gal", -- Gallons of conventional (petroleum) diesel fuel used.
    "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.
    "typeofservicecd", -- Describes how public transportation services are provided by the transit agency: directly operated (DO) or purchased transportation (PT) services.
    "modecd", -- A system for carrying transit passengers described by specific right-of-way (ROW), technology and operational features.
    "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.
    "city", -- The city in which the agency is headquartered.
    "hydrogen_kg_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.
    "hydrogen_kg_", -- Kilograms of hydrogen used.
    "compressed_natural_gas_mpg", -- Miles per gallon for compressed natural gas-powered vehicles.
    "hydrogen_mpkg_", -- Miles per kilogram for hydrogen-powered vehicles.
    "electric_propulsion_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.
    "electric_battery_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.
    "electric_battery_mi_kwh_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.
    "hydrogen_mpkg_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.
    "electric_battery_kwh_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.
    "diesel_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.
    "other_fuel_mpg_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-fuel-and-energy-8ehq-7his:latest"."2022_ntd_annual_data_fuel_and_energy"
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-fuel-and-energy-8ehq-7his 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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his: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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his

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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his:latest

This will download all the objects for the latest tag of datahub-transportation-gov/2022-ntd-annual-data-fuel-and-energy-8ehq-7his 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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his: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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his: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/2022-ntd-annual-data-fuel-and-energy-8ehq-7his is just another Postgres schema.

Related Documentation:

Loading...