I'm looking for best practices (plugins, procedures...) in QGIS to generate an HTML document (which later on can be finalized in MS Word) in which the result of spatial queries can be documented.

An example: I have a layer with parcels of a municipality. I would like to generate a document, according to a pre-defined HTML layout, where the results of overlays of this parcel with other geographic layers (e.g. legal boundaries) are included. E.g. in my document, there is a question "is the parcel located within an agricultural area?" and behind the question there are two checkboxes (yes and no) which should be checked depending on the result of a spatial overlay between the selected parcel and the layer with agricultural areas.

In addition to the above-mentioned spatial query, it would be also useful to include in the HTML-document the information from some attribute fields from the layer with agricultural areas (e.g. name of the agricultural area) in case the parcel overlaps with an agricultural area?

Are there any easy-to-use plugins or tools for this in QGIS?


I recently did something similar, but I was embedding the html in a pdf. I made a Python script that the user can run from the processing toolbox. Check out this tutorial for a guide on how to set one up.

The basic idea is to perform some analysis and use the print composer to automatically generate the output.

Here is a Python snippet from my own code to get you started on the html side. Since my output was a pdf I've omitted the rendering part. This should give you an idea of how to save the composer as an html document though.

#Replace capitalised words with your data 

layer = QgsVectorLayer("C:/YOUR SHAPEFILE.shp", "A NAME YOU LIKE", "ogr")

#set up composer
c = QgsComposition(mr) 
c.setPaperSize(210, 297) 
dpi = c.printResolution() 

#Add the information 
infoBox = QgsComposerLabel(c)
infoBox.setItemPosition(25, 15)
message = '''<H1>TITLE</H1>

newMessage = message.format(value=layer.attribute("YOUR ATTRIBUTE"))

  • Thanks. Do you know any solutions (plugins, tools...) for which no knowledge on Python is required? – Stijn Claes Sep 26 '17 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.