add support for OGC API - Coverages (#110) (#516)

* add support for OGC API - Coverages

* fix coverage CRS ref

* fix ref to OACov schemas for testing

* move spectral testing to after_success

* update docs

* add mask param to rasterio provider
This commit is contained in:
Tom Kralidis
2020-08-21 09:52:17 -04:00
committed by GitHub
parent b98f8c2528
commit da824fba8f
38 changed files with 1824 additions and 322 deletions
+6 -1
View File
@@ -158,12 +158,17 @@ default.
# see pygeoapi.plugin for supported providers
# for custom built plugins, use the import path (e.g. mypackage.provider.MyProvider)
# see Plugins section for more information
- type: feature # underlying data geospatial type: (allowed values are: feature)
- type: feature # underlying data geospatial type: (allowed values are: feature, coverage)
default: true # optional: if not specified, the first provider definition is considered the default
name: CSV
data: tests/data/obs.csv # required: the data filesystem path or URL, depending on plugin setup
id_field: id # required for vector data, the field corresponding to the ID
time_field: datetimestamp # optional field corresponding to the temporal propert of the dataset
format: # optional default format
name: GeoJSON # required: format name
mimetype: application/json # required: format mimetype
options: # optional options to pass to provider (i.e. GDAL creation)
option_name: option_value
properties: # optional: only return the following properties, in order
- stn_id
- value
+1
View File
@@ -19,5 +19,6 @@ return back data to the pygeoapi API framework in a plug and play fashion.
:name: Data publishing
ogcapi-features
ogcapi-coverages
ogcapi-processes
stac
@@ -0,0 +1,68 @@
.. _ogcapi-coverages:
Publishing raster data to OGC API - Coverages
=============================================
`OGC API - Coverages`_ provides geospatial data access functionality to raster data.
To add raster data to pygeoapi, you can use the dataset example in :ref:`configuration`
as a baseline and modify accordingly.
Providers
---------
pygeoapi core feature providers are listed below, along with a matrix of supported query
parameters.
.. csv-table::
:header: Provider, rangeSubset, subsets
:align: left
rasterio,✔️,✔️,✔️,
Below are specific connection examples based on supported providers.
Connection examples
-------------------
rasterio
^^^^^^^^
The `rasterio`_ provider plugin reads and extracts any data that rasterio is
capable of handling.
.. code-block:: yaml
providers:
- type: coverage
name: rasterio
data: tests/data/CMC_glb_TMP_TGL_2_latlon.15x.15_2020081000_P000.grib2
options: # optional creation options
DATA_ENCODING: COMPLEX_PACKING
format:
name: GRIB2
mimetype: application/x-grib2
Data access examples
--------------------
- list all collections
- http://localhost:5000/collections
- overview of dataset
- http://localhost:5000/collections/foo
- coverage rangetype
- http://localhost:5000/collections/foo/coverage/rangetype
- coverage domainset
- http://localhost:5000/collections/foo/coverage/domainset
- coverage access via CoverageJSON (default)
- http://localhost:5000/collections/foo/coverage?f=json
- coverage access via native format (as defined in ``provider.format.name``)
- http://localhost:5000/collections/foo/coverage?f=GRIB2
- coverage access with comma-separated rangeSubset
- http://localhost:5000/collections/foo/coverage?rangeSubset=1,3
- coverage access with subsetting
- http://localhost:5000/collections/foo/coverage?subset=lat(10,20)&subset=long(10,20)
.. _`OGC API - Coverages`: https://github.com/opengeospatial/ogc_api_coverages
.. _`rasterio`: https://rasterio.readthedocs.io
+4 -2
View File
@@ -10,8 +10,8 @@ Features
- out of the box modern OGC API server
- certified OGC Compliant and Reference Implementation for OGC API - Features
- additionally implements OGC API - Processes and SpatioTemporal Asset Library
- out of the box data provider plugins for GDAL/OGR, Elasticsearch, PostgreSQL/PostGIS
- additionally implements OGC API - Coverages, OGC API - Processes and SpatioTemporal Asset Library
- out of the box data provider plugins for rasterio, GDAL/OGR, Elasticsearch, PostgreSQL/PostGIS
- easy to use OpenAPI / Swagger documentation for developers
- supports JSON, GeoJSON, HTML and CSV output
- supports data filtering by spatial, temporal or attribute queries
@@ -36,6 +36,7 @@ Standards are at the core of pygeoapi. Below is the project's standards support
:widths: 20, 20
`OGC API - Features`_,Reference Implementation
`OGC API - Coverages`_,Implementing
`OGC API - Processes`_,Implementing
`SpatioTemporal Asset Catalog`_,Implementing
@@ -43,5 +44,6 @@ Standards are at the core of pygeoapi. Below is the project's standards support
.. _`pygeoapi`: https://pygeoapi.io
.. _`OGC API`: https://ogcapi.ogc.org
.. _`OGC API - Features`: https://www.ogc.org/standards/ogcapi-features
.. _`OGC API - Coverages`: https://github.com/opengeospatial/ogc_api_coverages
.. _`OGC API - Processes`: https://github.com/opengeospatial/wps-rest-binding
.. _`SpatioTemporal Asset Catalog`: https://stacspec.org
+63 -12
View File
@@ -38,22 +38,22 @@ pygeoapi for easier maintenance of software updates.
updates and package management
Example: custom pygeoapi data provider
--------------------------------------
Example: custom pygeoapi vector data provider
---------------------------------------------
Lets consider the steps for a data provider plugin (source code is located here: :ref:`data Provider`).
Lets consider the steps for a vector data provider plugin (source code is located here: :ref:`data Provider`).
Python code
^^^^^^^^^^^
The below template provides a minimal example (let's call the file ``mycooldata.py``:
The below template provides a minimal example (let's call the file ``mycoolvectordata.py``:
.. code-block:: python
from pygeoapi.provider.base import BaseProvider
class MyCoolDataProvider(BaseProvider):
"""My cool data provider"""
class MyCoolVectorDataProvider(BaseProvider):
"""My cool vector data provider"""
def __init__(self, provider_def):
"""Inherit from parent class"""
@@ -91,7 +91,7 @@ The below template provides a minimal example (let's call the file ``mycooldata.
For brevity, the above code will always return the single feature of the dataset. In reality, the plugin
developer would connect to a data source with capabilities to run queries and return relevant a result set,
developer would connect to a data source with capabilities to run queries and return a relevant result set,
as well as implement the ``get`` method accordingly. As long as the plugin implements the API contract of
its base provider, all other functionality is left to the provider implementation.
@@ -104,23 +104,23 @@ The following methods are options to connect the plugin to pygeoapi:
**Option 1**: Update in core pygeoapi:
- copy ``mycooldata.py`` into ``pygeoapi/provider``
- copy ``mycoolvectordata.py`` into ``pygeoapi/provider``
- update the plugin registry in ``pygeoapi/plugin.py:PLUGINS['provider']`` with the plugin's
shortname (say ``MyCoolData``) and dotted path to the class (i.e. ``pygeoapi.provider.mycooldata.MyCoolDataProvider``)
shortname (say ``MyCoolVectorData``) and dotted path to the class (i.e. ``pygeoapi.provider.mycoolvectordata.MyCoolVectorDataProvider``)
- specify in your dataset provider configuration as follows:
.. code-block:: yaml
providers:
- type: feature
name: MyCoolData
name: MyCoolVectorData
data: /path/to/file
id_field: stn_id
**Option 2**: implement outside of pygeoapi and add to configuration (recommended)
- create a Python package of the ``mycooldata.py`` module (see `Cookiecutter`_ as an example)
- create a Python package of the ``mycoolvectordata.py`` module (see `Cookiecutter`_ as an example)
- install your Python package onto your system (``python setup.py install``). At this point your new package
should be in the ``PYTHONPATH`` of your pygeoapi installation
- specify in your dataset provider configuration as follows:
@@ -129,10 +129,61 @@ The following methods are options to connect the plugin to pygeoapi:
providers:
- type: feature
name: mycooldatapackage.mycooldata.MyCoolDataProvider
name: mycooldatapackage.mycoolvectordata.MyCoolVectorDataProvider
data: /path/to/file
id_field: stn_id
BEGIN
Example: custom pygeoapi raster data provider
---------------------------------------------
Lets consider the steps for a raster data provider plugin (source code is located here: :ref:`data Provider`).
Python code
^^^^^^^^^^^
The below template provides a minimal example (let's call the file ``mycoolrasterdata.py``:
.. code-block:: python
from pygeoapi.provider.base import BaseProvider
class MyCoolRasterDataProvider(BaseProvider):
"""My cool raster data provider"""
def __init__(self, provider_def):
"""Inherit from parent class"""
BaseProvider.__init__(self, provider_def)
self.num_bands = 4
self.axes = ['Lat', 'Long']
def get_coverage_domainset(self):
# return a CIS JSON DomainSet
def get_coverage_rangetype(self):
# return a CIS JSON RangeType
def query(self, bands=[], subsets={}, format_='json'):
# process bands and subsets parameters
# query/extract coverage data
if format_ == 'json':
# return a CoverageJSON representation
return {'type': 'Coverage', ...} # trimmed for brevity
else:
# return default (likely binary) representation
return bytes(112)
For brevity, the above code will always JSON for metadata and binary or CoverageJSON for the data. In reality, the plugin
developer would connect to a data source with capabilities to run queries and return a relevant result set,
As long as the plugin implements the API contract of its base provider, all other functionality is left to the provider
implementation.
Each base class documents the functions, arguments and return types required for implementation.
END
Example: custom pygeoapi formatter
----------------------------------