OGC API Features with pygeoapi
In this recipe we’ll set up an instance of pygeoapi with some soil data. A good practice is available on how to provide an INSPIRE download service based on OGC API Features. pygeoapi is an open source python server implementation of OGCAPI Features, Tiles, Maps, Coverages, Records and Processes.
Quick start
The recipe is based on Docker. New to docker? Read more in the Docker recipe.
- With commandline in a new folder, run this command:
docker run -p 5000:80 geopython/pygeoapi:latest
- Navigate with your browser to http://localhost:5000
If all went fine, you now see the default pygeoapi installation with sample data. In the next step we’ll publish a new soil dataset. pygeoapi’s configuration is stored in a config file. The config file is encoded as YAML. The first part configures the main settings of the service, in the second part individual datasets are configured.
- Download the Dutch INSPIRE dataset ‘soil drills’ from https://service.pdok.nl/bzk/brobhrpvolledigeset/atom/v1_1/downloads/brobhrpvolledigeset.zip
- Unzip the file to the work folder
- Create a local config file in the folder, download it from here
- Remove all the datasets from the config folder, and replace it for the following:
resources:
bro:
type: collection
title: BRO
description: Bro soil drills
keywords:
- soil
links:
- type: application/geopackage+sqlite
rel: canonical
title: source data
href: https://service.pdok.nl/bzk/brobhrpvolledigeset/atom/v1_1/downloads/brobhrpvolledigeset.zip
hreflang: en-US
extents:
spatial:
bbox: [-180,-90,180,90]
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
providers:
- type: feature
name: OGR
data:
source_type: GPKG
source: /pygeoapi/brobhrpvolledigeset.gpkg
gdal_ogr_options:
SHPT: POINT
id_field: bro_id
layer: borehole_research
- Mount config file in containter
docker run -p 5000:80 -v ${PWD}/pygeoapi-config.yml:/pygeoapi/local.config.yml -v ${PWD}/brobhrpvolledigeset.gpkg:/pygeoapi/brobhrpvolledigeset.gpkg geopython/pygeoapi:latest
Validation
JRC recently extended the INSPIRE validator. It can now also validate an OGC API Features service. Because docker runs locally, you need to set up a tunnel for the validator to access the local service. Read the tunnel recipe to see how to do that.
Read more
At masterclass edition 2023 Tom Kralidis presented the geopython ecosystem, including pygeoapi.
The geopython community has prepared a workshop on getting started with pygeoapi.