Quantcast
Channel: QGIS Planet
Viewing all articles
Browse latest Browse all 1090

Kartoza: How to load a QGIS project in python

$
0
0

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:

QGIS project in a standalone app

 

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!


Viewing all articles
Browse latest Browse all 1090

Trending Articles