datahub-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc
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 watershed_reach_index_and_problem_scores table in this repository, by referencing it like:

"datahub-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc:latest"."watershed_reach_index_and_problem_scores"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "index_aquatic_life", -- Aquatic Life Index score.  100 = best condition. (Bugs, diatoms abundance, diversity, pollution tolerance and other metrics)
    "index_water_quality", -- Water Quality Index score. 100 = best condition. (nutrients, temp, tss)
    "index_source_type", -- EII - Environmental Integrity Index or ALI - Austin Lakes Index 
    "problem_fertilizer", -- Fertilizer problem score (creeks only). 100 = worst condition. Nitrate.
    "index_vegetation", -- Vegetation Index score (for lakes only). 100 = best condition.
    "watershed_id", -- This is a foreign key to the system-assigned primary key to the  "Official Watershed List"  https://data.austintexas.gov/Government/Watersheds/ec78-i9z5  for the City of Austin.  1 to 1 relation with Watershed_Name. Even if Barton Creek is renamed, it will always have an ID of 1.
    "index_non_contact_recreation", -- Non Contact Recreation Index score (creeks only). 100 = best condition. Aesthetics, odor, safety.
    "problem_stability", -- Stability problem score (creeks only). 100 = worst condition. Stream bank failures.
    "index_habitat", -- Habitat Index score. 100 = best condition. Instream cover and substrate niches.
    "modified_by",
    "fiscal_year_of_observation", -- The City of Austin Fiscal year the data points are associated with. FY 2014 started on 01-OCT-2013 and ended 30-SEP-2014.
    "watershed_name", -- Official watershed name from this list: https://data.austintexas.gov/Government/Watersheds/ec78-i9z5
    "watershed_reach_id", -- Primary Varchar key for this dataset. 1 is most downstream reach and ascends for subsequent upstream reaches in the same watershed.
    "integrity_score_id", -- Primary Integer Key for this dataset.
    "problem_sewage", -- Sewage problem score (creeks only). 100 = worst condition. Water Quality problem caused by sewage.
    "problem_water_quality", -- Water Quality problem score (creeks only). 100 = worst condition. Water quality worst case.
    "problem_construction_runoff", -- Construction TSS Problem score (creeks only). 100 = worst condition.  Erosion and Sedimentation controls failure.
    "problem_riparian_vegetation", -- Riparian Vegetation problem score (creeks only). 100 = worst condition. Not enough riparian cover.
    "created_by",
    "problem_sediment", -- Sediment problem score (creeks only). 100 = worst condition. Worst of the problems set score.
    "index_reach_score", -- Overall Index Score. 100 = best condition.  Average of other index scores. Problem scores not included.
    "problem_animal_waste", -- Animal Problem score (creeks only). 100 = worst condition. Pet waste.
    "index_sediment", -- Sediment Index score. 100 = best condition. Metals, pcbs, pesticides average.
    "created_date",
    "index_eutrophication", -- Eutrophication Index score (for lakes only). 100 = best condition. In general, lower chlorophyll-a abundance and lower proportion of blue-green algae lead to a higher score to represent a superior trophic condition.
    "problem_litter", -- Litter problem score (creeks only). 100 = worst condition. Trash
    "index_phase", -- For streams only - one of two phases.  Lakes all collected in same phase.
    "modified_date",
    "index_contact_recreation" -- Contact Recreation Index score (for creeks only). 100 = best condition.  (bacteria)
FROM
    "datahub-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc:latest"."watershed_reach_index_and_problem_scores"
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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc 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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc: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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc

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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc:latest

This will download all the objects for the latest tag of datahub-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc 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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc: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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc: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-austintexas-gov/watershed-reach-index-and-problem-scores-vk3r-6prc is just another Postgres schema.

Related Documentation:

Loading...