Exercise 4 - Maps of geospatial data via OGC API - Maps¶
OGC API - Maps provides a Web API to access any geospatial data as a georeferenced map image.
pygeoapi support¶
pygeoapi supports the OGC API - Maps specification, using MapServer MapScript and a WMS facade as core backends.
Note
See the official documentation for more information on supported map backends
Publish a raster dataset¶
In this section we'll be exposing a Geopackage file available at workshop/exercises/data/airport.gpkg location using MapServer MapScript. This data can be consumed with various clients which are compliant with OGC APIs - Maps. List of few such clients can be found here. Here we can also pass style in .sld format. Which can be generated on Geoserver, QGIS, etc.
Interact with OGC API - Maps via MapScript
Open the pygeoapi configuration file in a text editor. Find the line # START - EXERCISE 4 - Maps.
Uncomment section related to #airports.
Note
See the official documentation for more information on supported map backends
pygeoapi as a WMS proxy¶
You can check the "pygeoapi as a Bridge to Other Services" section to learn how to publish WMS as OGC API - Maps.
Client access¶
QGIS¶
QGIS added support for API's providing rendered image layers via its raster support.
Add OGC API - Maps layer to QGIS
- Install a recent version of QGIS (>3.28).
- Open the
Add raster layer panel. - Select
OGCAPIfor Source type. - Add the local endpoint as source
http://localhost:5000/collections/airports. - Select
PNGas image format. - Finally add the layer to the map.
OWSLib¶
OWSLib is a Python library to interact with OGC Web Services and supports a number of OGC APIs including OGC API - Maps.
Interact with OGC API - Maps via OWSLib
If you do not have Python installed, consider running this exercise in a Docker container. See the Setup Chapter.
Now running in Python:
Note
See the official OWSLib documentation for more examples.
Summary¶
Congratulations! You are now able to serve an OGC WMS via pygeoapi and OGC API - Maps.