Outdated version of the documentation. Find the latest one here.


OGC データサーバとしての QGIS

QGIS Serverは、オープンソースWMS1.3とWFS1.0.0の実装だけでなく,それに加え,主題マッピングのための高度な地図作成機能を実装しています. QGIS サーバはwebサーバ(例. Apache, Lighttpd)と一緒に動作するC++で書かれたFastCGI/CGI(Common Gateway Interface)アプリケーションです.これはEUのプロジェクトオーケストラ,Sanyとスイスウスター市が資金提供しています.

QGIS サーバは QGIS をGISロジックと地図レンダリングのバックエンドとして利用しています. さらに Qt ライブラリがグラフィックスとプラットフォームから独立したC++プログラミングに利用されています. 他のWMS ソフトウェアと対比して QGIS サーバはカルトグラフィックルールを構成言語として利用しています, それはサーバ構成とユーザ定義のカルトグラフィックルールの両方です.

As QGIS desktop and QGIS Server use the same visualization libraries, the maps that are published on the web look the same as in desktop GIS.

次のマニュアルの1つでは, QGIS サーバをセットアップするための設定のサンプルを提供します.しかし、我々は,詳細を得るために次のURLの1つを読むことをお勧めします:

Debian Squeezeのインストールサンプル

この時点で,Debian SqueezeのためのHowToとなる短くて簡単なサンプル設定を提供します.他の多くのOSが QGIS サーバのためにパッケージを提供しています.もしソースからすべてを構築する必要がある場合は,上記ののURLを参照してください.

Apart from QGIS and QGIS Server, you need a web server, in our case apache2. You can install all packages with aptitude or apt-get install together with other necessary dependency packages. After installation, you should test to confirm that the web server and QGIS Server work as expected. Make sure the apache server is running with /etc/init.d/apache2 start. Open a web browser and type URL: http://localhost. If apache is up, you should see the message ‘It works!’.

ここで QGIS サーバインストレーションのテストをしましょう. qgis_mapserv.fcgi/usr/lib/cgi-bin/qgis_mapserv.fcgi で使えるはずです,そして標準WMS でAlaskaの州境界線が表示されるはずです. Selecting WMS/WMTS Servers に記述されているように URL http://localhost/cgi-bin/qgis_mapserv.fcgi をWMSとして追加して下さい.

Figure Server 1:


USA 境界線を含んだ QGIS サーバーの標準WMS(KDE) nix

Creating a WMS/WFS/WCS from a QGIS project

新しい QGIS サーバから WMS, WFS または WCSを配信するためには, なんらかのデータを使って QGIS プロジェクトファイルを作らなければいけません. ここでは QGIS サンプルデータセットの ‘Alaska’ shapefileを使いましょう. 指定が無い場合は QGIS で色とスタイルとプロジェクトのCRSを指定して下さい.

Figure Server 2:


Definitions for a QGIS Server WMS/WFS/WCS project (KDE)

Then, go to the OWS Server menu of the Project ‣ Project Properties dialog and provide some information about the OWS in the fields under Service Capabilities. This will appear in the GetCapabilities response of the WMS, WFS or WCS. If you don’t check checkbox Service capabilities, QGIS Server will use the information given in the wms_metadata.xml file located in the cgi-bin folder.

WMS capabilities

In the WMS capabilities section, you can define the extent advertised in the WMS GetCapabilities response by entering the minimum and maximum X and Y values in the fields under Advertised extent. Clicking Use Current Canvas Extent sets these values to the extent currently displayed in the QGIS map canvas. By checking checkbox CRS restrictions, you can restrict in which coordinate reference systems (CRS) QGIS Server will offer to render maps. Use the mActionSignPlus button below to select those CRS from the Coordinate Reference System Selector, or click Used to add the CRS used in the QGIS project to the list.

If you have print composers defined in your project, they will be listed in the GetCapabilities response, and they can be used by the GetPrint request to create prints, using one of the print composer layouts as a template. This is a QGIS-specific extension to the WMS 1.3.0 specification. If you want to exclude any print composer from being published by the WMS, check checkbox Exclude composers and click the mActionSignPlus button below. Then, select a print composer from the Select print composer dialog in order to add it to the excluded composers list.

If you want to exclude any layer or layer group from being published by the WMS, check checkbox Exclude Layers and click the mActionSignPlus button below. This opens the Select restricted layers and groups dialog, which allows you to choose the layers and groups that you don’t want to be published. Use the Shift or Ctrl key if you want to select multiple entries at once.

あなたは GetFeatureInfo リクエストをプレインテキスト XML と GMLの形式で受け取ることができます. デフォルトは XMLです, テキストまたは GML形式はGetFeatureInfo リクエストの出力用に選択されたときに利用されます.

If you wish, you can check checkbox Add geometry to feature response. This will include in the GetFeatureInfo response the geometries of the features in a text format. If you want QGIS Server to advertise specific request URLs in the WMS GetCapabilities response, enter the corresponding URL in the Advertised URL field. Furthermore, you can restrict the maximum size of the maps returned by the GetMap request by entering the maximum width and height into the respective fields under Maximums for GetMap request.

If one of your layers uses the Map Tip display (i.e. to show text using expressions) this will be listed inside the GetFeatureInfo output. If the layer uses a Value Map for one of his attributes, also this information will be shown in the GetFeatureInfo output.

WFS capabilities

In the WFS capabilities area, you can select the layers that you want to publish as WFS, and specify if they will allow the update, insert and delete operations. If you enter a URL in the Advertised URL field of the WFS capabilities section, QGIS Server will advertise this specific URL in the WFS GetCapabilities response.

WCS capabilities

In the WCS capabilities area, you can select the layers that you want to publish as WCS. If you enter a URL in the Advertised URL field of the WCS capabilities section, QGIS Server will advertise this specific URL in the WCS GetCapabilities response.

Now, save the session in a project file alaska.qgs. To provide the project as a WMS/WFS, we create a new folder /usr/lib/cgi-bin/project with admin privileges and add the project file alaska.qgs and a copy of the qgis_mapserv.fcgi file - that’s all.

Now we test our project WMS, WFS and WCS. Add the WMS, WFS and WCS as described in WMS/WMTS レイヤの読み込み, WFS および WFS-T クライアント and WCS クライアント to QGIS and load the data. The URL is:



For vector layers, the Fields menu of the Layer ‣ Properties dialog allows you to define for each attribute if it will be published or not. By default, all the attributes are published by your WMS and WFS. If you want a specific attribute not to be published, uncheck the corresponding checkbox in the WMS or WFS column.

You can overlay watermarks over the maps produced by your WMS by adding text annotations or SVG annotations to the project file. See section Annotation Tools in 一般ツール for instructions on creating annotations. For annotations to be displayed as watermarks on the WMS output, the Fixed map position check box in the Annotation text dialog must be unchecked. This can be accessed by double clicking the annotation while one of the annotation tools is active. For SVG annotations, you will need either to set the project to save absolute paths (in the General menu of the Project ‣ Project Properties dialog) or to manually modify the path to the SVG image in a way that it represents a valid relative path.

WMS GetMapリクエストでサポートされているエキストラパラメータ

WMS GetMap リクエストで, QGIS サーバーは OCG WMS 1.3.0 スペシケーションにしたがった標準パラメータ以外にいくつかの拡張パラメータを受け付けます:

  • MAP parameter: Similar to MapServer, the MAP parameter can be used to specify the path to the QGIS project file. You can specify an absolute path or a path relative to the location of the server executable (qgis_mapserv.fcgi). If not specified, QGIS Server searches for .qgs files in the directory where the server executable is located.


  • DPI パラメータ: DPI パラメータでは要求される出力解像度の指定に使われます.


  • OPACITIES パラメータ: 透明度はレイヤかグループ単位に指定できます. 指定できる値の範囲は 0 (完全に透明) から 255 (完全に不透明)です.



QGIS Server logging

To log requests send to server, set the following environment variables:

  • QGIS_SERVER_LOG_FILE: Specify path and filename. Make sure that server has proper permissions for writing to file. File should be created automatically, just send some requests to server. If it’s not there, check permissions.

  • QGIS_SERVER_LOG_LEVEL: Specify desired log level. Available values are:

    • 0 INFO (log all requests),
    • 1 WARNING,
    • 2 CRITICAL (log just critical errors, suitable for production purposes).


    SetEnv QGIS_SERVER_LOG_FILE /var/tmp/qgislog.txt


  • When using Fcgid module use FcgidInitialEnv instead of SetEnv!
  • Server logging is enabled also if executable is compiled in release mode.

Environment variables

  • QGIS_OPTIONS_PATH: The variable specifies path to directory with settings. It works the same ways as QGIS application –optionspath option. It is looking for settings file in <QGIS_OPTIONS_PATH>/QGIS/QGIS2.ini. For exaple, to set QGIS server on Apache to use /path/to/config/QGIS/QGIS2.ini settings file, add to Apache config:

    SetEnv QGIS_OPTIONS_PATH "/path/to/config/"