Exercise 9 - pygeoapi as a bridge to other services
In this section we explore how pygeoapi can be used as a facade, or a bridge, to re-publish web services with different interfaces. These bridges can help organisations migrating from OWS to OGC API.
Publishing WFS as OGC API - Features
A powerful use case for pygeoapi is to provide an OGC API - Features interface over existing Web Feature Service (WFS) or ESRI FeatureServer endpoints. In this scenario, you lower the barrier and increase the usability of existing services to a wider audience. Let's set up an API on top of an existing WFS hosted by the city of Florence.
Update the pygeoapi configuration
Open the pygeoapi configuration in a text editor.
Find the line # START - EXERCISE 8 - WFS Proxy
.
Add a new dataset section by uncommenting the lines up to # END - EXERCISE 8 - WFS Proxy
:
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 29 30 31 32 33 34 35 36 37 38 39 |
|
Save the file and restart Docker Compose. Navigate to http://localhost:5000/collections to evaluate whether the new dataset has been published.
Note these important configuration slices under providers
:
-
We use the pygeoapi OGR Provider. This is the most versatile backend of pygeoapi for supporting numerous formats. Using the GDAL/OGR library (Python bindings) allows pygeoapi to connect to around 80+ Vector Formats. We could have used the
OGR
Provider instead of theSQLiteGPKG
Provider above in theosm_places-vec
exercise above. -
storage_crs
denotes the CRS (Coordinate Reference System) in which the dataset is stored (default is CRS84, i.e. 'longitude, latitude') crs
is an array of CRSs that can be specified for the Features to be returned (crs=
parameter), or for their bounding box (bbox-crs=
parameter). Default is also CRS84.
CRS support effectively allows pygeoapi to reproject the data from its storage CRS (here EPSG:3003) according to OGC API - Features - Part 2: Coordinate Reference Systems by Reference. The Advanced section of this workshop will further elaborate pygeoapi CRS support.
Publishing WMS as OGC API - Maps
We can use the pygeoapi's WMSFacade provider to publish OGC Web Map Service (WMS) interfaces as OGC API - Maps.
Let's set up an API on top of an existing WMS on the MapServer Demonstration Server:
https://demo.mapserver.org/cgi-bin/msautotest
Note
Feel free to use an WMS of your choice, as you wish!
Update the pygeoapi configuration
Open the pygeoapi configuration in a text editor.
Find the line ## START - EXERCISE 8 - WMS Proxy
.
Add a new dataset section by uncommenting the lines up to ## END - EXERCISE 8 - WMS Proxy
:
Be sure to keep the proper YAML indentation.
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 |
|
Run the following requests in your web browser:
- default map: http://localhost:5000/collections/wms-facade-demo/map?f=png
- specific width/height: http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600
- specific area of interest (bbox of Canada): http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600&bbox=-142,42,-52,84
Tip
Try with your own bbox and width/height values!
Publishing CSW as OGC API - Records
In this section we'll have a look at how to publish Catalogue Service for the Web (CSW) as OGC API - Records. For that, we will use the pycsw OGC CITE demo CSW service.
Update the pygeoapi configuration
Open the pygeoapi configuration in a text editor.
Find the line # START - EXERCISE 8 - CSW Proxy
.
Add a new dataset section by uncommenting the lines up to # END - EXERCISE 8 - CSW Proxy
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
You can explore the proxied catalogue collection using this endpoints:
- collection metadata page: http://localhost:5000/collections/cite_demo
- list of records: http://localhost:5000/collections/cite_demo/items
- record: http://localhost:5000/collections/cite_demo/items/urn:uuid:19887a8a-f6b0-4a63-ae56-7fba0e17801f
Tip
Remember that you can use the QGIS client suggested here to explore this API.
Publishing SensorThings API as OGC API - Features
The OGC SensorThings API standard offers RESTfull interfaces to interconnect IoT devices, data, in an open and unified way. Although there are some clients that support this standard, there are many more that support OGC API - Features.
The pygeoapi SensorThings bridge enables to proxy the SensorThings entities (e.g.: Thing
, Sensor
, DataStream
, ObservedProperty
) into feature collections.
In this section we'll have a look at how to Publish a SensorThings API Thing
as an OGC API - Features collection, which can then be consumed by various clients, like the ones listed here
Update the pygeoapi configuration
Open the pygeoapi configuration in a text editor.
Find the line # START - EXERCISE 8 - SensorThings Proxy
.
Add a new dataset section by uncommenting the lines up to # END - EXERCISE 8 - SensorThings Proxy
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|