Skip to content

Exercise 3 - Raster data via OGC API - Coverages

OGC API - Coverages provides a Web API to access raster data (grids, remote sensing data, multidimensional data cubes):

pygeoapi support

pygeoapi supports the OGC API - Coverages draft specification, with rasterio and xarray as core backends as well as CoverageJSON and native output.

Note

See the official documentation for more information on supported raster backends

Publish a raster dataset

In the previous exercises we have demonstrated the steps involved to publish vector data and update the pygeoapi configuration. In this section we are going to publish a raster file in GeoTIFF format, from a rasterio source provider.

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
tartu-ntl:
    type: collection
    title: NASA Blue Marble Night Lights Data sample over Estonia
    description: NASA Blue Marble Night Lights Data sample over Estonia
    keywords:
        - Blue Marble
        - Night Lights
        - NTL
    links:
        - type: text/html
          rel: about
          title: NASA Blue Marble Night Lights Data
          href: https://appliedsciences.nasa.gov/get-involved/training/english/arset-introduction-nasas-black-marble-night-lights-data
          hreflang: en
    extents:
        spatial:
          bbox: [26.6264,58.32569,26.82632,58.433989]
          crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
    providers:
        - type: coverage
          name: rasterio
          data: /data/tartu/estonia_light.tif # place correct path here
          format:
              name: GTiff
              mimetype: application/tiff

Tip

The rasterio provider format.name directive requires a valid GDAL raster driver short name

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

Client access

GDAL/OGR

GDAL/OGR provides support for OGC API - Coverages. This means you can use gdalinfo to query and convert data from OGC API - Coverages endpoints just like any other raster data source. This also means you can make connections to OGC API - Coverages endpoints from any software which has an interface to GDAL, such as MapServer, GeoServer, Manifold, FME, ArcGIS, etc.

Use GDAL to interact with OGC API - Coverages

  • Verify you have a recent GDAL installed, else use GDAL from OSGeoLive
  • Run gdalinfo on the command line to verify a connection to OGC API - Coverages:

gdalinfo OGCAPI:https://maps.ecere.com/ogcapi/collections/SRTM_ViewFinderPanorama

OWSLib

OWSLib is a Python library to interact with OGC Web Services and supports a number of OGC APIs including OGC API - Coverages.

Interact with OGC API - Coverages via OWSLib

If you do not have Python installed, consider running this exercise in a Docker container. See the Setup Chapter.

pip3 install owslib

>>> from owslib.ogcapi.coverages import Coverages
>>> SERVICE_URL = 'https://demo.pygeoapi.io/master/'
>>> w = Coverages(SERVICE_URL)
>>> w.url
'https://demo.pygeoapi.io/master/'
>>> gdps = w.collection('gdps-temperature')
>>> gdps['id']
'gdps-temperature'
>>> gdps['title']
'Global Deterministic Prediction System sample'
>>> gdps['description']
'Global Deterministic Prediction System sample'
>>> schema = w.collection_schema('gdps-temperature')
>>> len(schema['field'])
1
>>> schema['properties']['1']['title']
'Temperature [C]'
>>> schema['properties']['1']['x-ogc-unit']
'[C]'
>>> schema['properties']['1']['type']
'number'

Note

See the official OWSLib documentation for more examples.

Summary

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