noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut

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 procotol. 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 oregon_chum_salmon_size_at_age_and_environmental table in this repository, by referencing it like:

"noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut:latest"."oregon_chum_salmon_size_at_age_and_environmental"

or in a full query, like:

SELECT 
    ":id", -- Socrata column ID
    "group_no_yaquina_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from all Oregon rivers except Yaquina.
    "miami_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from Miami R, Oregon.
    "group_no_yaquina_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from all Oregon rivers except Yaquina.
    "yaquina_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from Yaquina R, Oregon.
    "cui_aut", -- Coastal upwelling index, autumn (45 degrees N latitude).
    "cui_sum", -- Coastal upwelling index, summer (45 degrees N latitude).
    "pdo_spr", -- Pacific Decadal Oscillation, spring (45 degrees N latitude).
    "pdo_sum", -- Pacific Decadal Oscillation, summer (45 degrees N latitude).
    "pdo_aut", -- Pacific Decadal Oscillation, autumn (45 degrees N latitude).
    "pdo_win", -- Pacific Decadal Oscillation, winter (45 degrees N latitude).
    "cui_win", -- Coastal upwelling index, winter  (45 degrees N latitude).
    "cui_spr", -- Coastal upwelling index, spring (45 degrees N latitude).
    "miami_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from Miami R, Oregon.
    "all_five_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from all five Oregon rivers.
    "kilchis_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from Kilchis R, Oregon.
    "miami_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from Miami R, Oregon.
    "biotrans", -- Date of biological transition (45 degrees N latitude).
    "junecoho", -- June coho catch per unit effort (45 degrees N latitude).
    "sprtransui", -- Spring transition upwelling index (45 degrees N latitude).
    "yaquina_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from Yaquina R, Oregon.
    "junecpue", -- June salmon catch per unit effort (45 degrees N latitude).
    "nehalem_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from Nehalem R, Oregon.
    "all_five_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from all five Oregon rivers.
    "scopbiomass", -- Biomass anomaly of southern copepods sampled (45 degrees N latitude).
    "upwelling_apr_may", -- Upwelling, April-May (45 degrees N latitude).
    "sprtranshydro", -- Spring hydrological transition (45 degrees N latitude).
    "winterichthyo", -- Winter ichthyoplankton ordination score (45 degrees N latitude).
    "lengthuiseason", -- Length of the upwelling index season (45 degrees N latitude).
    "ncopbiomass", -- Biomass anomaly of northern copepods sampled (45 degrees N latitude).
    "cci", -- Copepod community index ordination score (45 degrees N latitude).
    "year_", -- The year that the data were taken.
    "nehalem_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from Nehalem R, Oregon.
    "wilson_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from Wilson R, Oregon.
    "nehalem_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from Nehalem R, Oregon.
    "nh05_sst_may_sep", -- Sea surface temperature at station 46050.
    "deepsal", -- Salinity at 50 m depth (45 degrees N latitude).
    "deeptemp", -- Temperature at 50 m depth (45 degrees N latitude).
    "kilchis_fk_lg_age_3", -- Mean fork length of age 3 adult chum salmon from Kilchis R, Oregon.
    "coprichness", -- Species diversity anomaly of sampled copepods (45 degrees N latitude).
    "pdo_may_sep", -- Pacific Decadal Oscillation, May to September (45 degrees N latitude).
    "pdo_dec_mar", -- Pacific Decadal Oscillation, December to March (45 degrees N latitude).
    "oni", -- Oceanic Nino Index (45 degrees N latitude).
    "nh05_sst_nov_mar", -- Sea surface temperature at station 46050.
    "sst_46050", -- Sea surface temperature at station 46050.
    "wilson_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from Wilson R, Oregon.
    "yaquina_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from Yaquina R, Oregon.
    "group_no_yaquina_fk_lg_age_4", -- Mean fork length of age 4 adult chum salmon from all Oregon rivers except Yaquina.
    "wilson_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from Wilson R, Oregon.
    "kilchis_fk_lg_age_5", -- Mean fork length of age 5 adult chum salmon from Kilchis R, Oregon.
    "all_five_fk_lg_age_5" -- Mean fork length of age 5 adult chum salmon from all five Oregon rivers.
FROM
    "noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut:latest"."oregon_chum_salmon_size_at_age_and_environmental"
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 noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at noaa-fisheries-nwfsc.data.socrata.com. When you querynoaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut: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)"
 

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 noaa-fisheries-nwfsc.data.socrata.com, 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 \
  "noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut" \
  --handler-options '{
    "domain": "noaa-fisheries-nwfsc.data.socrata.com",
    "tables": {
        "oregon_chum_salmon_size_at_age_and_environmental": "n9su-p3ut"
    }
}'

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, noaa-fisheries-nwfsc-data-socrata/oregon-chum-salmon-size-at-age-and-environmental-n9su-p3ut is just another Postgres schema.

Related Documentation: