Skip to content

whatnick/demo_qgis_app

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
 
 
 
 
 
 
 
 

Sample Standalone QGIS App for windows

  • This application shows how to build a custom windows application using QGIS as a library
  • It is very bare bones and displays
    • Load OSM Maptiles using an XYZ Layer
    • Load static ecw raster data for Canberra 100K mapsheet form a hardcoded path
    • Load static vector data for Australian airports from a hardcoded path
  • Launch the application from OSGeo4W CLI or standard cli using C:\OSGeo4W64\bin\python-qgis qgis_demo.py

Developer Setup

  • Launch VSCode and start a new python project
  • Select Python3.7 that ships with Osgeo4W64 as the interpreter
  • Install pyinstalller via pip
  • Run application from python as above
  • Build stand-alone .exe file using build_exe.bat

Developer Setup

Packaging executable for Windows

PyInstaller is recommended for folder / single file based distribution of the QGIS application. There is a nice tutorial / answer on StackOverflow. This approach is included here for distribution of the application. It involves 2 steps:

  • Detecting the mode in which PyInstaller is running and setting paths accordingly
  • A spec file to cleanly setup options to pack the binary

To get the packaging tooling install pyinstaller via pip into the OSGeo4W python 3.7 environment ( current as of 28-09-2020). Python3-pip must be installed as a package in the osgeo4w setup. It is safer to pack a heavier directory based version of the application to avoid possible DLL hell due to different versions of QGIS being installed on the user machine compared to the developers. Install pyinstaller from PyPI, python3 -m pip install setuptools pyinstaller should work on most platforms.

Sample Data Attribution

Sample Code Attribution

Application Screenshot

About

Barebones QGIS Stand-alone app to demonstrate using PyQGIS to build custom GIS applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published