Qgis-server...Bringing a map image into the browser on Ubuntu 16.04 LTS

So you have your 'GetCapabilities' xml displaying in your browser working as in my post of Friday 22nd July 2016


NO?...here are some issues to check back in the QGIS project file before we move on.

  • Check the 'Project Properties' under the 'Project' menu, go to the 'OWS server' tab. Below is an example of of how I've set up mine.

 and here is the bottom bit you cannot see in the above image...

Ensure under 'Save Paths' in the 'General' Tab it is set to 'relative'. Note that the layers you are going to select for the WMS service are ticked under 'Published' in the WFS capabilities table.

Moving on to setting up your 'Add layer(s) from WM(T)S Server' button on the 'Manage Layers Toolbar'

Ensure your url is pointing at 'http://yourhost/cgi-bin/project/qgis_mapserv.fcgi?'it is better to specify the full path to the qgis project file which is stored (in my case) in a 'project' folder inside the 'cgi-bin' folder along with any shapefiles used as the source of your wms, 'qgis_mapserv.fcgi' file and 'wms_metadata.xml' files.

Now create a new connection and add your parameters which should look similar to the ones i've added above and tick 'ignore GetMap' and 'ignore GetFeatureInfo' boxes are ticked then 'OK'. In your 'project' folder under 'cgi-bin' (/usr/lib/cgi-bin/project/southuk.qgs)

Since we are using one layer from a PostGIS database open you 'Project.qgs' file (in Gedit or similar text editor and ensure you add your PostGIS connection details similar to below under <datasource>. I understand you can leave out the password as it is already stored in the 'pgpass.conf' file. I've left this in for demo purposes.

amend the <datasource> line to reflect your PostGIS database connection details.

When your done...check again using the same URL as before:


If ever you need to share your WMS Service with another QGIS user you can use the url (below) and you will get a list of all the layers from that project.

How do we display a map image from our QGIS Desktop project file?

Before we do go back in your QGIS project check you can add your newly created WMS layers back into QGIS as with any other WMS from a different source.

When you hit the 'connect' button you should see a list of layers you created earlier, if not go back and check from the beginning of this post.

Select a layer and click 'Add' and the layer(s) should appear in your layer panel as normal qgis layers.

Lastly, r/c on your largest area wms layer and go to 'Properties' and make a note of the bounding box co-ordinates.

The layer extent is from left to right 262377,179121,297597,215872

We can now use these co-ordinates in the 'GetMap' part in the url:-


http://localhost/cgi-bin/project/qgis_mapserv.fcgi? this part of the url locates the qgis-server executable on the apache2 host server.

SERVICE=WMS&VERSION=1.3.0&SRS=EPSG:27700& this part calls the WMS service, it's version and the target spatial reference system.

REQUEST=GetMap&map=/usr/lib/cgi-bin/project/southuk.qgs& this part is the request to get the 'map' from the qgis project file.

BBOX=262377,179121,297597,2158721&WIDTH=550&HEIGHT=500& this part sets the size of the retrieved image boundary and the 'WIDTH' and 'HEIGHT' of the image area in the browser.

LAYERS=coast_polyline,b_road_polyline&STYLES=,,&FORMAT=image/png the final part is the description and display of the layers of the WMS. Note there is no 'STYLES' specified because it in specified the .qgs file. Finally, the output format is a png image.

The final output is a png image in the browser window.

and a closer look shows it is identical to the qgis project.

We could also add many more parameters and requests into the url in order to enhance the visual appearance for example.

REQUEST=GetFeatureInfo...this request retrieves the underlying attributes and geometry values and pixel location.

GetLegendGraphic...this looks for the view legend information.

bgcolor...sets the background map colour.



  1. Hi Paul, Thanks for this tutorial.

    1. Great Article android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. TreasureBox is operated by a group of young, passionate, and ambitious people that are working diligently towards the same goal - make your every dollar count, as we believe you deserve something better.
    entertainment unit
    furniture nz


Post a Comment

Popular posts from this blog

Qgis-server...Installing the QGIS Lizmap Plugin & Lizmap Web Client

Qgis-server...Installation on Ubuntu 16.04 LTS

Overlaying Raster and Vector datasets with different projection parameters in GRASS GIS