A QGIS Server Plugin to render GEOJSON with QML styling.
With this plugin installed, your QGIS server will be able to render a geojson file to a PNG image. The geojson file can be a local file or downloaded from a network service. A qml file can be provided to define the rendering style of the geojson.
It works almost like WMS, except that the source of the data and the symbology are dynamic and must be provided as url parameter. There is also no such thing as GetCapabilities
.
git clone https://github.com/opengisch/qgis_server_render_geojson.git
cd qgis_server_render_geojson
docker-compose up
And navigate to
http://localhost:8080/ogc/?SERVICE=RenderGeojson&STYLE=polygon_outline.qml&WIDTH=300&HEIGHT=600&GEOJSON=polygon.geojson&BBOX=2689574,1283976,2689673,1284099
- Download https://github.com/opengisch/qgis_server_render_geojson/archive/master.zip
- Unzip and copy the
qgis_server_render_geojson
folder to a local qgis server plugin path (check: metadata.txt must be in[plugin_path]/qgis_server_render_geojson/metadata.txt
) - Configure the local plugin path by setting it in apache, nginx, (your favorite webserver)
QGIS_PLUGINPATH=[plugin_path]
- Restart server
The request supports the following parameters:
Path to the GeoJson file. May be a URI or relative to the prefix in the configuration.
Relative to configured prefix path:
GEOJSON=naturgefahren%2Fdata.json
Absolute path (url encoded https://api.sh.ch/v1/get_geojson?topic=naturgefahren
):
GEOJSON=https%3A%2F%2Fapi.sh.ch%2Fv1%2Fget_geojson%3Ftopic%3Dnaturgefahren
Path to a qml file. May be a URI or relative to the prefix in the configuration.
The substitution variable $type
is available which will be replaced with points
, lines
or polygons
.
Static:
STYLE=naturgefahren%2Fbase.qml
Dynamic:
STYLE=naturgefahren%2F$type.qml
This will lookup up to 3 styles:
naturgefahren/points.qml
naturgefahren/lines.qml
naturgefahren/polygons.qml
The bounding box to render. Needs to match the CRS of the data in the provided GeoJSON file.
BBOX=2689634.3,1283792.7,2690062.1,1284004.8
The width of the result image in pixels.
WIDTH=640
The height of the result image in pixels.
HEIGHT=480
The dpi used to render the symbology.
DPI=96
Basic request that will search data and style in the prefix directory (see configuration)
GET /qgis_mapserv.fcgi?SERVICE=RENDERGEOJSON&GEOJSON=data.json&STYLE=style.qml&BBOX=2689634.3,1283792.7,2690062.1,1284004.8&WIDTH=606&HEIGHT=300&DPI=96
Basic request that will search data and style in the prefix directory (see configuration)
GET /qgis_mapserv.fcgi?SERVICE=RENDERGEOJSON&GEOJSON=data.json&STYLE=$type.qml&BBOX=2689634.3,1283792.7,2690062.1,1284004.8&WIDTH=606&HEIGHT=300&DPI=96
Basic request that will create another request to collect data from another resource
GET /qgis_mapserv.fcgi?SERVICE=RENDERGEOJSON&GEOJSON=https%3A%2F%2Fapi.sh.ch%2Fv1%2Fget_geojson%3Fregion%3Dschaffhausen&STYLE=https%3A%2F%2Fapi.sh.ch%2Fstyle%3Fnaturgefahren.qml%26type%3F$type&BBOX=2689634.3,1283792.7,2690062.1,1284004.8&WIDTH=606&HEIGHT=300&DPI=96
The prefix path where local (sytle and geojson) files are provided can be defined throug an environment variable QGIS_RENDERGEOJSON_PREFIX
.