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

http://www.paulshapley.com/2016/07/how-to-install-qgis-server-on-ubuntu.html

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:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

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.

http://127.0.0.1/cgi-bin/projects/my_project/qgis_mapserv.fcgi?SERVICE=WFS&REQUEST=GetCapabilities

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?SERVICE=WMS&VERSION=1.3.0&SRS=EPSG:27700&REQUEST=GetMap&map=/usr/lib/cgi-bin/project/southuk.qgs&BBOX=262377,179121,297597,2158721&WIDTH=550&HEIGHT=500&LAYERS=coast_polyline,b_road_polyline&STYLES=,,&FORMAT=image/png

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.





 




Comments

  1. Hi Paul, Thanks for this tutorial.

    ReplyDelete
    Replies
    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

      Delete
  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.
    Mattress
    entertainment unit
    furniture nz

    ReplyDelete
  3. "It’s the ideal a chance to make a number of plans for the longer term and it’s time for you to be at liberty. We have learn this publish of course, if I could..I wish to counsel you few interesting issues or advice. Perhaps you can write next articles regarding this short article.

    I wish to read more things approximately it!"

    ��야동 ��

    ReplyDelete
  4. "What’s up, ☑오피☑ of course this piece of writing is truly good and I have learned lot of things from it about blogging. thanks."

    ReplyDelete
  5. "It’s amazing ↘마사지↙, your posts are really impressive, I hope to see more of this wonderful article from you"

    ReplyDelete
  6. What an excellent you are. Your presentation was so good. 💥건전마사지💥

    ReplyDelete
  7. Great web site. A lot of useful information here. I’m sending it to several friends ans also sharing in delicious. And obviously, thanks in your effort! 야설
    Feel free to visit my blog :
    야설

    ReplyDelete
  8. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. 일본야동
    Feel free to visit my blog : e 일본야동

    ReplyDelete
  9. I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates.
    야설
    Feel free to visit my blog : 야설

    ReplyDelete
  10. Ucuz, kaliteli ve organik sosyal medya hizmetleri satın almak için Ravje Medyayı tercih edebilir ve sosyal medya hesaplarını hızla büyütebilirsin. Ravje Medya ile sosyal medya hesaplarını organik ve gerçek kişiler ile geliştirebilir, kişisel ya da ticari hesapların için Ravje Medyayı tercih edebilirsin. Ravje Medya internet sitesine giriş yapmak için hemen tıkla: ravje.com

    İnstagram takipçi satın almak için Ravje Medya hizmetlerini tercih edebilir, güvenilir ve gerçek takipçilere Ravje Medya ile ulaşabilirsin. İnstagram takipçi satın almak artık Ravje Medya ile oldukça güvenilir. Hemen instagram takipçi satın almak için Ravje Medyanın ilgili sayfasını ziyaret et: instagram takipçi satın al

    Tiktok takipçi satın al istiyorsan tercihini Ravje Medya yap! Ravje Medya uzman kadrosu ve profesyonel ekibi ile sizlere Tiktok takipçi satın alma hizmetide sunmaktadır. Tiktok takipçi satın almak için hemen tıkla: tiktok takipçi satın al

    İnstagram beğeni satın almak için Ravje medya instagram beğeni satın al sayfasına giriş yap, hızlı ve kaliteli instagram beğeni satın al: instagram beğeni satın al

    Youtube izlenme satın al sayfası ile hemen youtube izlenme satın al! Ravje medya kalitesi ile hemen youtube izlenme satın almak için tıklayın: youtube izlenme satın al

    Twitter takipçi satın almak istiyorsan Ravje medya twitter takipçi satın al sayfasına tıkla, Ravje medya güvencesi ile organik twitter takipçi satın al: twitter takipçi satın al

    ReplyDelete
  11. İnstagram takipçi satın al! İnstagram takipçi sitesi ile takipçi satın al sende sosyal medyada fenomen olmaya bir adım at. Sende hemen instagram takipçi satın almak istiyorsan tıkla:

    1- takipçi satın al

    2- takipçi satın al

    3- takipçi satın al

    ReplyDelete

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