Install

pygeoapi is nativally run as a Flask app (the code struct is an API and Flask is used as a wrapper).

pygeoapi uses two configuration files: pygeoapi-config.yml and openapi.yml. First configuration contains all the information and setup to run pygeoapi while the second is exclusivally for the openapi.

pygeoapi requires setting PYGEOAPI_CONFIG and PYGEOAPI_OPENAPI env variable. PYGEOAPI_CONFIG points to the yaml file containing the configuration, in the example bellow we copy the local.config.yml default configuration to pygeoapi-config.yml and use this configuration file.

PYGEOAPI_OPENAPI variable is the path to openapi file configuration, this file needs to be autogenerated using the pygeoapi generate-openapi-document command and the pygeoapi config files e.g: pygeoapi generate-openapi-document -c local.config.yml > openapi.yml. And then setting the env variable to the path: export PYGEOAPI_OPENAPI=/path/to/openapi.yml

For production environments it is recommended to use Docker or a specialized WSGI HTTP server WSGI

Copy/paste install

It is advisable to run pygeoapi inside an isolated enviroment either virtualenv or docker, mainly to avoid python package conflicts.

#create virtualenv
virtualenv -p python pygeoapi
cd pygeoapi
. bin/activate
git clone https://github.com/geopython/pygeoapi.git
cd pygeoapi

#install requirements
pip install -r requirements.txt
pip install -r requirements-dev.txt

# install source in current directory
pip install -e .
cp pygeoapi-config.yml local.config.yml
#edit configuration file
nano  local.config.yml

export PYGEOAPI_CONFIG=/path/to/local.config.yml
# generate OpenAPI Document
pygeoapi generate-openapi-document -c local.config.yml > openapi.yml
export PYGEOAPI_OPENAPI=/path/to/openapi.yml

#Run pygeoapi
pygeoapi serve

If the default configuration was used then we should have pygeoapi running on

_images/openapi_intro_page.png