All Projects → 3liz → py-qgis-wps

3liz / py-qgis-wps

Licence: MPL-2.0, MIT licenses found Licenses found MPL-2.0 LICENSE.txt MIT PYWPS_LICENSE.txt
An implementation of the Web Processing Service standard from the Open Geospatial Consortium based on the QGIS processing API

Programming Languages

python
139335 projects - #7 most used programming language
QML
638 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
CSS
56736 projects

Projects that are alternatives of or similar to py-qgis-wps

qgis3d
3D map view - proof of concept using Qt 3D
Stars: ✭ 39 (+18.18%)
Mutual labels:  qgis
DsgTools
DSG's QGIS Plugin for GIS production
Stars: ✭ 37 (+12.12%)
Mutual labels:  qgis
isogeo-plugin-qgis
Isogeo plugin for QGIS
Stars: ✭ 13 (-60.61%)
Mutual labels:  qgis
albion
Migrated to: https://gitlab.com/Oslandia/albion
Stars: ✭ 47 (+42.42%)
Mutual labels:  qgis
qgis-epanet
Project migrated to : https://gitlab.com/Oslandia/qgis/qgis-epanet
Stars: ✭ 36 (+9.09%)
Mutual labels:  qgis
DEMto3D-QGIS-Plugin
Extensión GIS para impresión 3D de MDE
Stars: ✭ 33 (+0%)
Mutual labels:  qgis
ilong
轻量级跨平台瓦片地图库,大部分算法来自QMapControl,就想练手的。。。因为需要轻量级跨平台的,所以只能先用SQLite数据库。。。
Stars: ✭ 24 (-27.27%)
Mutual labels:  qgis
gis4wrf
QGIS toolkit 🧰 for pre- and post-processing 🔨, visualizing 🔍, and running simulations 💻 in the Weather Research and Forecasting (WRF) model 🌀
Stars: ✭ 137 (+315.15%)
Mutual labels:  wps
UMapControl
轻量级跨平台瓦片地图库
Stars: ✭ 35 (+6.06%)
Mutual labels:  qgis
py-qgis-server
QGIS embbeded WMS/WFS/WCS asynchronous scalable http server
Stars: ✭ 28 (-15.15%)
Mutual labels:  qgis
QGISFMV
QGIS Full Motion Video (FMV)
Stars: ✭ 104 (+215.15%)
Mutual labels:  qgis
g3w-admin
Server module for G3W-SUITE
Stars: ✭ 24 (-27.27%)
Mutual labels:  qgis
gisportal
GIS portal and Administration part of Extended QGIS Web Client
Stars: ✭ 19 (-42.42%)
Mutual labels:  qgis
qgis-kmltools-plugin
Fast KML Import and Export Plugin for QGIS
Stars: ✭ 45 (+36.36%)
Mutual labels:  qgis
input
Survey made easy (Android/iOS/Windows app)
Stars: ✭ 189 (+472.73%)
Mutual labels:  qgis
qgis-bridge-plugin
GeoCat Bridge is a plugin for QGIS that can be used to publish geospatial (meta)data to the cloud.
Stars: ✭ 24 (-27.27%)
Mutual labels:  qgis
formation-postgis
Formation PostGIS pour les utilisateurs de QGIS
Stars: ✭ 16 (-51.52%)
Mutual labels:  qgis
QGIS-visualization-workshop
QGIS visualization workshop materials.
Stars: ✭ 46 (+39.39%)
Mutual labels:  qgis
qgis-maptiler-plugin
QGIS MapTiler Plugin: vector tiles, basemaps, geocoding, OSM, QuickMapServices
Stars: ✭ 73 (+121.21%)
Mutual labels:  qgis
xyz-qgis-plugin
Plugin for QGIS to connect to the HERE XYZ Hub API
Stars: ✭ 22 (-33.33%)
Mutual labels:  qgis

Py-QGIS-WPS

PyPi version badge PyPI - Downloads PyPI - Python Version

New in 1.8: OGC api processes support

Py-QGIS-WPS is an implementation of the Web Processing Service standard from the Open Geospatial Consortium based on the QGIS Processing API.

Since 1.8 Py-QGIS-WPS supports OGC API REST processes api

This implementation allows you to expose and run on a server:

  • QGIS Processing algorithms available on Desktop
  • QGIS Processing models and scripts
  • QGIS plugins having a Processing provider according to their metadata.txtfile

It is written in Python and was originally a fork of PyWPS.

Requirements and limitations :

  • Python 3.7 minimum
  • Windows not officially supported
  • Redis server

Documentation

Latest documentation is available on docs.3liz.org

Why Py-QGIS-WPS ?

Py-QGIS-WPS differs from PyWPS in the following:

  • QGIS centric
  • Handle all request in asynchronous way: all jobs run in a non-blocking way, even when synchronous operation is requested.
  • Use multiprocessing Pool to handle task queue instead instantiating a new process each time.
  • Uniform Logging with the 'logging' module
  • Implements OGC processes api.
  • Use Redis for asynchronous status storage.
  • Support streamed/chunked requests for stored data
  • Add extensions to WPS: TIMEOUT and EXPIRE
  • No Windows support

All these changes where not easy to implement without some drastic changes of the original code and we think that it deviates too much from the PyWPS original intentions.

That is, we have decided to fork the original project and go along with it.

So, we are really grateful to the original authors of PyWPS for the nice piece of software that helped us very much to start quickly this project.

Why moving to Tornado instead WSGI

  • We need to support asyncio: asyncio requires a blocking running loop. This cannot be achieved simply in a WSGI architecture.
  • Tornado is fully integrated with native python asyncio library and provide a great framework for developing a http server.

Extensions to WPS

TIMEOUT extension

Specify the timeout for a process: if the process takes more than TIMEOUT seconds to run, the worker is then killed and an error status is returned.

Set the TIMEOUT=<seconds> in GET requests.

In POST requests, set the timeout=<seconds> attribut in the <ResponseDocument> tag.

The server may configure maximum timeout value.

EXPIRE extension

Specify the expiration time for stored results: after EXPIRE seconds after the end of the wps process, all results will be flushed from disks and local cache. Trying to request the results again will return a 404 HTTP error.

Set the EXPIRE=<seconds> in GET requests.

In POST requests, set the expire=<seconds> attribut int the <ResponseDocument> tag.

The server may configure maximum expiration value.

Status API

Now implemented with the processes api: The status REST api will return the list of the stored status for all running and terminated wps processes.

Example for returning all stored status:

http://localhost:8080/jobs

Example for returning status for one given job from its id:

http://localhost:8080/jobs/<job_id>

Extensions to processes api:

Files

http://localhost:8080/jobs/<job_id>/files

Running QGIS processing

WPS input/output layer mapping

With QGIS desktop, QGIS processing algorithms usually apply on a QGIS source project and computed layers are displayed in the same context as the source project.

Py-qgis-wps works the same way: a qgis project will be used as a source of input layers. The difference is that, when an algorithm runs, it creates a qgis project file associated to the current task and register computed layers to it.

The created project may be used as OWS source with Qgis Server. Output layers are returned as complex objects holding a reference to a WMS/WFS uri that can be used directly with Qgis server. The uri template is configurable using the server/wms_response_uri configuration setting.

Contextualized input parameters

Tasks parameters are contextualized using the MAP query param. If a MAP parameters is given when doing a DescripProcess requests, allowed values for input layers will be taken from the qgis source project according the type of the input layers.

QGIS project (.qgs) files and project stored in Postgres databases are both supported.

The best practice is to always provide a MAP parameters and include the possible input layer in a qgs project. This way you may connect whatever data source supported by qgis and use them as input data in a safe way.

If you need to pass data to your algorithm from client-side, prefer inputs file parameter and small payloads.

Dependencies

See requirements.txt file.

Installation from python package

ADVICE: You should always install in a python virtualenv. If you want to use system packages, setup your environment with the --system-site-packages option.

See the official documentation for how to setup a python virtualenv: https://virtualenv.pypa.io/en/stable/.

From source

Install in development mode

make build
pip install -e .

From python package server

pip install py-qgis-wps

Running the server

The server from a command line interface:

The server does not run as a daemon by itself, there are several ways to run a command as a daemon.

For example:

  • Use Supervisor http://supervisord.org/ will give you full control over logs and server status notifications.
  • Use the daemon command.
  • Use Docker

Running the server

Usage

usage: wpsserver [-h] [-d] [-c [PATH]]
                 [--version] [-p PORT] [-b IP] [-u SETUID]

WPS server

optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           Set debug mode  
  -c [PATH], --config [PATH]
                        Configuration file
  --version             Return version number and exit
  -p PORT, --port PORT  http port
  -b IP, --bind IP      Interface to bind to
  -u SETUID, --setuid SETUID
                        uid to switch to

Requests to OWS services

The OWS requests use the following format: /ows/?<ows_query_params>

Example:

http://myserver:8080/ows/?SERVICE=WPS&VERSION=1.0.0&REQUEST=GetCapabilities

Configuration

From config ini file

By default, the wps server is not using any config file, but one can be used with the --config option. A config file is a simple ini file, a sample config file is given with the sources.

From environment variables

The server can be configured with environnement variables:

Configuration is done with environment variables:

  • QGSWPS_SERVER_WORKDIR: set the current dir processes, all processes will be running in that directory.
  • QGSWPS_SERVER_HOST_PROXY: When the service is behind a reverse proxy, set this to the proxy entrypoint.
  • QGSWPS_SERVER_PARALLELPROCESSES: Number of parallel process workers
  • QGSWPS_SERVER_RESPONSE_TIMEOUT: The max response time before killing a process.
  • QGSWPS_SERVER_RESPONSE_EXPIRATION: The max time (in seconds) the response from a WPS process will be available.
  • QGSWPS_SERVER_WMS_SERVICE_URL: The base url for WMS service. Default to /wms. Responses from processing will be retourned as WMS urls. This configuration variable set the base url for accessing results.
  • QGSWPS_SERVER_RESULTS_MAP_URI

Logging

  • QGSWPS_LOGLEVEL: the log level, should be INFO in production mode, DEBUG for debug output.

REDIS storage configuration

  • QGSWPS_REDIS_HOST: The redis host
  • QGSWPS_REDIS_PORT: The redis port. Default to 6379
  • QGSWPS_REDIS_DBNUM: The redis database number used. Default to 0

Qgis project Cache configuration

  • QGSWPS_CACHE_ROOTDIR: Absolute path to the qgis projects root directory, projects referenced with the MAP parameter will be searched at this location

Processing configuration

  • QGSWPS_PROCESSSING_PROVIDERS_MODULE_PATH: Path to look for processing algorithms provider to publish, algorithms from providers specified here will be runnable as WPS processes.

Exposing algorithms as WPS services

Note that since 1.1 , the __algorithms__.py method for declaring providers is no longer supported.

Processing providers following the same rules as Qgis regular plugin with a special factory entrypoint: WPSClassFactory(iface) in the __init__.py file.

The metadata.txt file

As regular QGIS plugin, a metadata.txt file must be present with a special entry wps=True indicating that the plugin is available as a WPS service provider.

Registering providers

The iface parameter is a instance of WPSServerInterface which provide a registerProvider( provider: QgsAlgorithmProvider, expose: bool = True) -> Any method.

Exposed providers as WPS services must be registered using the registerProvider method

Example:

def WPSClassFactory(iface: WPSServerInterface) -> Any:

    from TestAlgorithmProvider1 import  AlgorithmProvider1
    from TestAlgorithmProvider2 import  AlgorithmProvider2

    iface.registerProvider( AlgorithmProvider1() )
    iface.registerProvider( AlgorithmProvider2() )

Controlling what is exposed:

Processing algorithm with the flag FlagHideFromToolbox set will not be exposed as WPS process.

Parameters with the flag FlagHidden set won't be exposed in a DescribeProcess request

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].