Skip to content

Commit

Permalink
Merge pull request #132 from geopython/tk-updates-2023-12-15
Browse files Browse the repository at this point in the history
add Linux/Mac and Windows tabs, editorial updates
  • Loading branch information
doublebyte1 authored Dec 17, 2023
2 parents 02a3b55 + c43f15c commit 06b66c4
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 126 deletions.
28 changes: 10 additions & 18 deletions workshop/content/docs/advanced/bridges.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Exercise 8 - pygeoapi as a bridge to other services
title: Exercise 9 - pygeoapi as a bridge to other services
---

# Exercise 8 - pygeoapi as a bridge to other services
# 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](https://ogcapi-workshop.ogc.org/transition-and-migration).

Expand All @@ -15,11 +15,9 @@ a wider audience. Let's set up an API on top of an existing WFS hosted by the ci
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - WFS Proxy"
Find the line `# START - EXERCISE 8 - WFS Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - WFS Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - WFS Proxy`:


``` {.yaml linenums="1"}
Expand Down Expand Up @@ -97,11 +95,9 @@ We can use the pygeoapi's WMSFacade provider to publish OGC Web Map Service (WMS
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"## START - EXERCISE 8 - WMS Proxy"
Find the line `## START - EXERCISE 8 - WMS Proxy`.

Add a new dataset section by uncommenting the lines up to
"## END - 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.

Expand Down Expand Up @@ -153,11 +149,9 @@ In this section we'll have a look at how to publish Catalogue Service for the We
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - CSW Proxy"
Find the line `# START - EXERCISE 8 - CSW Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - CSW Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - CSW Proxy`:

``` {.yaml linenums="1"}
cite_demo:
Expand Down Expand Up @@ -203,11 +197,9 @@ In this section we'll have a look at how to Publish a SensorThings API `Thing` a
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - SensorThings Proxy"
Find the line `# START - EXERCISE 8 - SensorThings Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - SensorThings Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - SensorThings Proxy`:

``` {.yaml linenums="1"}
toronto_bikes:
Expand Down
37 changes: 25 additions & 12 deletions workshop/content/docs/advanced/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,36 @@ A [Docker image](https://hub.docker.com/r/geopython/pygeoapi) is available for p

<div class="termy">
```bash
docker run -p 5000:80 https://hub.docker.com/r/geopython/pygeoapi:latest
docker run -p 5000:80 geopython/pygeoapi:latest
```
</div>

!!! question "Review the pygeoapi docker file"
!!! question "Review the pygeoapi Dockerfile"

Notice in the [pygeoapi docker file](https://github.com/geopython/pygeoapi/Dockerfile) how the open api file is generated as part of the docker startup script.
Notice in the [pygeoapi Dockerfile](https://github.com/geopython/pygeoapi/Dockerfile) how the open api file is generated as part of the Docker startup script.

In a typical configuration one would override the default pygeoapi configuration file in the image with a customized one and include the data folder
In a typical configuration one would override the default pygeoapi configuration file in the image with a customized one and include the data folder:

!!! example "using custom configuration"

=== "Linux/Mac"

<div class="termy">
```bash
docker run -p 5000:80 \
-v $(pwd)/pygeoapi-config.yml:/pygeoapi/local.config.yml \
-v $(pwd)/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

=== "Windows"

<div class="termy">
```bash
docker run -p 5000:80 -v ${pwd}/pygeoapi-config.yml:/pygeoapi/local.config.yml -v ${pwd}/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

<div class="termy">
```bash
docker run -p 5000:80 \
-v $(pwd)/pygeoapi-config.yml:/pygeoapi/local.config.yml \
-v $(pwd)/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

Alternatively, you can build a fresh Docker image including both the configuration and data for the service.

Expand All @@ -42,7 +55,7 @@ COPY ./my.config.yml /pygeoapi/local.config.yml
You may have noticed that the pygeoapi configuration file includes a reference to the endpoint on which pygeoapi is published. This configuration should
match the public endpoint of the service (domain, path and port).

By default the pygeoapi Docker Image will run from the `root` path `/`. If you need to run from a sub-path and have all internal URLs correct you can
By default the pygeoapi Docker image will run from the `root` path `/`. If you need to run from a sub-path and have all internal URLs correct you can
set the `SCRIPT_NAME` environment variable.

<div class="termy">
Expand Down
3 changes: 1 addition & 2 deletions workshop/content/docs/advanced/crs.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ in CRSs like `http://www.opengis.net/def/crs/EPSG/0/4258` (ETRS89 latitude, long
!!! question "Add CRS to a pygeoapi configuration"

Open the pygeoapi configuration file in a text editor.
Find the line:
"# START - EXERCISE 2 - firenze-terrains"
Find the line `# START - EXERCISE 2 - firenze-terrain`

Update the dataset section with CRS support by replacing it with the snippet below:

Expand Down
2 changes: 1 addition & 1 deletion workshop/content/docs/advanced/semantic-web-linked-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ some aspects of the Semantic Web so the data can be traversed by Semantic Web aw
However you can also use SPARQL to query graphs of linked web resources. The SPARQL client traverses links between
the resources to locate the requested triples. [Jena ARQ](https://jena.apache.org/documentation/query/) is a command
line SPARQL client which is able to run such queries. Jena is quite difficult to set up, although there is a
[Docker Image](https://hub.docker.com/r/stain/jena) available. As an alternative we will use a web-based implementation
[Docker image](https://hub.docker.com/r/stain/jena) available. As an alternative we will use a web-based implementation
of the ARQ engine. Navigate to [https://demos.isl.ics.forth.gr/sparql-ld-endpoint](https://demos.isl.ics.forth.gr/sparql-ld-endpoint/)
and replace the query in the textbox with:

Expand Down
17 changes: 17 additions & 0 deletions workshop/content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ Exercises are indicated as follows:

A section marked like this indicates that you can try out the exercise.

!!! example "Example exercise with tabs"

A section marked like this indicates that you can try out the exercise and choose your environment (Linux/Mac or Windows).

=== "Linux/Mac"
<div class="termy">
```bash
docker run -p 5000:80 -v $(pwd)/default.config.yml:/pygeoapi/local.config.yml geopython/pygeoapi:latest
```
</div>
=== "Windows"
<div class="termy">
```bash
docker run -p 5000:80 -v ${pwd}/default.config.yml:/pygeoapi/local.config.yml geopython/pygeoapi:latest
```
</div>

Also you will notice tips and notes sections within the text:

!!! tip
Expand Down
2 changes: 1 addition & 1 deletion workshop/content/docs/publishing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ through the following exercises:
- [Exercise 6 - Metadata via OGC API - Records](ogcapi-records.md)
- [Exercise 7 - Environmental data via OGC API - Environmental Data Retrieval](ogcapi-edr.md)
- [Exercise 8 - Functions via OGC API - Processes](ogcapi-processes.md)
- [Exercise 9 - Functions via OGC API - Processes](ogcapi-processes.md)
- [Exercise 9 - pygeoapi as a bridge to other services](../advanced/bridges.md)
2 changes: 2 additions & 0 deletions workshop/content/docs/publishing/ogcapi-coverages.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ unzip 53.zip
```
</div>

If you do not have curl installed, copy the URL above to your web browser and save locally.

You can now add `53_ED1_G.tif` to pygeoapi:

!!! question "Update the pygeoapi configuration"
Expand Down
15 changes: 13 additions & 2 deletions workshop/content/docs/publishing/ogcapi-edr.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ Let's try publishing some ICOADS data via the EDR xarray plugin. The sample ICOA

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:
At first glance, the `icoads-sst` collection appears as a normal OGC API - Coverages collection. Let's look a bit closer at the collection 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](https://requests.readthedocs.io):
!!! question "Interact with OGC API - Environmental Data Retrieval via Python requests"

If you do not have Python installed, consider running this exercise in a Docker container. See the [Setup Chapter](../setup.md#using-docker-for-python-clients).

<div class="termy">
```bash
pip3 install requests
```
</div>


Currently there is limited client support for EDR. The example below provides a generic workflow using the [Python requests library](https://requests.readthedocs.io):

<div class="termy">
```python
Expand Down
14 changes: 6 additions & 8 deletions workshop/content/docs/publishing/ogcapi-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ Let's add the file `workshop/exercises/data/osm_places_kosovo.gpkg`:
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration file in a text editor.
Find the line:
"# START - EXERCISE 2 - osm_places"
Find the line `# START - EXERCISE 2 - osm_places`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 2 - osm_places":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 2 - osm_places`:

``` {.yaml linenums="1"}
osm_places-vec:
Expand Down Expand Up @@ -107,7 +105,7 @@ docker-compose up
```
</div>

This configuration snippet, enables publishing greater_hyderabad_municipal_corporation_ward_boundaries.geojson as OGC API - Features:
This configuration snippet, enables publishing the file `greater_hyderabad_municipal_corporation_ward_boundaries.geojson` as OGC API - Features:

``` {.yaml linenums="1"}
greater_hyderabad_municipal_corporation_ward_boundaries:
Expand All @@ -134,7 +132,7 @@ This configuration snippet, enables publishing greater_hyderabad_municipal_corpo
providers:
- type: feature
name: Elasticsearch
#Note elastic_search is the docker container of ES the name is defined in the docker-compose.yml
# note: elastic_search is the Docker container name as defined in docker-compose.ym
data: http://elastic_search:9200/greater_hyderabad_municipal_corporation_ward_boundaries
id_field: objectid
```
Expand Down Expand Up @@ -194,7 +192,7 @@ QGIS is one of the first GIS Desktop clients which added support for OGC API - F

!!! tip

Install and activate the `QGIS Network Logger` extension. It will display HTTP traffic within QGIS and is a valuable tool in debugging failing connections.
Activate the `Debugging/Development Tools Panel` (right click anywhere on the toolbar icons and select). It will display HTTP traffic within QGIS and is a valuable tool in debugging failing connections.

!!! note

Expand Down Expand Up @@ -241,7 +239,7 @@ QGIS is one of the first GIS Desktop clients which added support for OGC API - F
```
</div>

Then start a Python console session with: `python` (stop the session by typing `exit()`).
Then start a Python console session with: `python3` (stop the session by typing `exit()`).

<div class="termy">
```python
Expand Down
2 changes: 1 addition & 1 deletion workshop/content/docs/publishing/ogcapi-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In this section we'll be exposing a Geopackage file available at `workshop/exerc

!!! question "Interact with OGC API - Maps via MapScript"

Open the pygeoapi configuration file in a text editor. Find the line: "# START - EXERCISE 5 - Maps".
Open the pygeoapi configuration file in a text editor. Find the line `# START - EXERCISE 5 - Maps`.

Uncomment section related to #airports.

Expand Down
55 changes: 52 additions & 3 deletions workshop/content/docs/publishing/ogcapi-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ develop your own custom pygeoapi plugin, or convert your metadata to OGC API - R

### Sample ISO 19139 to TinyDBCatalogue loader

It is possible to load more example ISO19139 metadata in a TinyDB database with [the following script](https://github.com/geopython/pygeoapi/blob/master/tests/load_tinydb_records.py) ([raw](https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py))

It is possible to load more example ISO19139 metadata in a TinyDB database with [the following script](https://github.com/geopython/pygeoapi/blob/master/tests/load_tinydb_records.py) ([raw](https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py)):

<div class="termy">
```bash
Expand All @@ -89,6 +88,56 @@ python3 load_tinydb_records.py xml catalogue.tinydb
```
</div>

If you do not have curl installed, copy the URL above to your web browser and save locally.

If you do not have Python installed, you can the loader by using the OWSLib Docker container. See the [Setup Chapter](../setup.md#using-docker-for-python-clients).

!!! example "Using the OWSLib Docker container to load metadata"

=== "Linux/Mac"
<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm --network=host --name owslib -v $(pwd)/data:/data python:3.10-slim /bin/bash
pip3 install owslib
apt-get update -y && apt-get install curl -y
curl -O https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py
python3 load_tinydb_records.py /data/records/xml /data/records/catalogue.tinydb
```
</div>

=== "Windows"
<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm --network=host --name owslib -v $(pwd)/data:/data python:3.10-slim /bin/bash
pip3 install owslib
apt-get update -y && apt-get install curl -y
curl -O https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py
python3 load_tinydb_records.py /data/records/xml /data/records/catalogue.tinydb
```
</div>

Navigate to <http://localhost:5000/collections/example_catalogue> to evaluate whether the new metadata has been published
to the collection.

!!! tip pygeometa

[pygeometa](https://geopython.github.io/pygeometa) is a Python package to generate metadata for geospatial
datasets. pygeometa allows for managing metadata in simple YAML "metadata control files (MCF), and supports
import, export as well as transformations for many geospatial metadata formats. OGC API - Records metadata
can be produced using pygeometa, either from MCF files or transforming from other formats.

Install and run pygeometa per below to get an idea of the various commands and functionality (as well,
consult the [tutorial](https://geopython.github.io/pygeometa/tutorial)).

<div class="termy">
```bash
pip3 install pygeometa
pygeometa --help
```
</div>

## pygeoapi as a CSW proxy

You can check the "pygeoapi as a Bridge to Other Services" section to learn how to [publish CSW as OGC API - Records](../../advanced/bridges/#publishing-csw-as-ogc-api-records).
Expand Down Expand Up @@ -129,7 +178,7 @@ QGIS supports OGC API - Records via the [MetaSearch plugin](https://docs.qgis.or
```
</div>

Then start a Python console session with: `python` (stop the session by typing `exit()`).
Then start a Python console session with: `python3` (stop the session by typing `exit()`).

<div class="termy">
```python
Expand Down
Loading

0 comments on commit 06b66c4

Please sign in to comment.