I'm using QGIS Desktop (version 2.18.3 on Windows) and have a python script that works in the python console. My script:

  1. Loads a shapefile (of properties in a city, identified by a PropertyID)
  2. Searches and zooms into a specific property (currently for testing purposes, the PropertyID is hardcoded)
  3. Loads a print composer template and displays the property from the above step
  4. Using the "Maps Printer" plugin, exports the print composer as a PNG

Everything in my script works correctly in QGIS' python console. Now I would like to call this python script from a web page. Ideally, it would be:

  1. Web page lets the user enter a PropertyID
  2. Web page passes that PropertyID to my python script, which then generates the PNG and then displays it to the user

Is my web interface scenario possible and if so, what would be the easiest way to achieve this?

I looked at installing QGIS Server (as opposed to QGIS Desktop), but I couldn't find a way to execute my script (and also pass in my PropertyID as a parameter)

As an automation test, I also tried running QGIS through the command line:

qgis --nologo --project "MyProject.qgs" --code "MyScript.py"

But while it created the PNG, it never updated the map whenever I tried changing the PropertyID in the script itself - plus it's not a scalable solution for multiusers.

I'm open to any suggestions on how to achieve this, even if it requires changing to a Unix platform.

1 Answer 1


After some research and testing, it looks like QGIS Server is the way to go. I can filter the shapefile, and save the output as an PNG or PDF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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