Explore Kartoza

Try searching for: QGIS, Training, GeoNode, PostGIS

How to Load a QGIS Project in Python
Back to Blog
Qgis
January 21, 2015 Gavin Fleming

How to Load a QGIS Project in Python

Loading a QGIS project in python

Today in a project we are working on we wanted to load a QGIS project. It takes surprisingly few lines of code to make a small standalone application that loads a project and then shows it as a map in a window like this:

Here is the code I wrote to produce this:

The main bit of magic is the QgsLayerTreeMapCanvasBridge class which will convert your project into a layer tree so that the layers appear in the canvas. If you ever need to make a standalone python application with a nice map in it, consider using the QGIS API to do it!

Want to Learn More?

Explore our training courses or get in touch to discuss how we can help your organisation.