Skip to content

Exercise 7 - Environmental data via OGC - Environmental Data Retrieval

OGC API - Environmental Data Retrieval provides a Web API to access environmental data using well defined query patterns:

OGC API - Environmental Data Retrieval uses OGC API - Features as a building block, thus enabling streamlined integration for clients and users. EDR can be considered a convenience API which does not require in depth knowledge about the underlying data store/model.

pygeoapi support

pygeoapi supports the OGC API - Environmental Data Retrieval specification by leveraging both feature and coverage provider plugins.

Note

See the official documentation for more information on supported EDR backends

Publish environmental data in pygeoapi

Let's try publishing some ICOADS data via the EDR xarray plugin. The sample ICOADS data can be found in workshop/exercises/data/coads_sst.nc:

Update the pygeoapi configuration

Open the pygeoapi configuration file in a text editor. Add a new dataset section as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    icoads-sst:
        type: collection
        title: International Comprehensive Ocean-Atmosphere Data Set (ICOADS)
        description: International Comprehensive Ocean-Atmosphere Data Set (ICOADS)
        keywords:
            - icoads
            - sst
            - air temperature
        extents:
            spatial:
                bbox: [-180,-90,180,90]
                crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
            temporal:
                begin: 2000-01-16T06:00:00Z
                end: 2000-12-16T06:00:00Z
        links:
            - type: text/html
              rel: canonical
              title: information
              href: https://psl.noaa.gov/data/gridded/data.coads.1deg.html
              hreflang: en-US
        providers:
            - type: edr
              name: xarray-edr
              data: /data/coads_sst.nc
              format:
                  name: NetCDF
                  mimetype: application/x-netcdf

Save the configuration and restart Docker Compose. Navigate to http://localhost:5000/collections to evaluate whether the new dataset has been published.

At first glance, the icoads-sst collection appears as a normal OGC API - Coverages collection. Let's look a bit closer at the colleciton description:

Client access

Currently there is no support for EDR in common tooling. The example below provides a generic workflow using the Python requests library:

>>> import requests
>>> collection = requests.get('http://localhost:5000/collections/icoads-sst').json()
>>> collection['id']
'icoads-sst'
>>> collection['title']
'International Comprehensive Ocean-Atmosphere Data Set (ICOADS)'
>>> collection['description']
'International Comprehensive Ocean-Atmosphere Data Set (ICOADS)'
>>> collection['parameter-names'].keys()
dict_keys(['SST', 'AIRT', 'UWND', 'VWND'])
>>> params = {'coords': 'POINT(-28 14)', 'parameter-name': 'SST'}
>>> position_query = requests.get('http://localhost:5000/collections/icoads-sst/position', params=params).json()
>>> position_query['ranges']['SST']['values']
[26.755414962768555, 26.303892135620117, 26.512916564941406, 26.799564361572266, 27.48826026916504, 28.04759979248047, 28.745832443237305, 28.5635986328125, 28.272104263305664, 28.526521682739258, 28.25160026550293, 27.074399948120117]

Summary

Congratulations! You are now able to publish environmental data to pygeoapi.