GEOG 489
Advanced Python Programming for GIS

4.12 Optional: Turning the Bus Event Analyzer into a QGIS Plugin

PrintPrint

As said at the beginning of Section 4.11, this section about turning the Bus Track Analyzer code into a plugin that adds new layers to the current QGIS project and displays the analysis progress live on the map canvas can be considered optional. Feel free to just briefly skim through it and then watch the video from Section 4.12.7 showing the final Bus Track Analyzer for QGIS plugin. While creating a QGIS plugin yourself is one option that would give you full over&above points in this lesson's homework assignment, the content of these two sections is not required for the assignment and the quiz. You can always come back to this section if you have time left at the end of this lesson or after the end of the class.

Now that you know how to create plugins for QGIS, let us apply this new knowledge to create a QGIS plugin version of our bus event analyzer from Section 4.10. We will call this plugin “Bus Track Analyzer for QGIS”. The process for this will be roughly as follows:

  • Set up a new plugin with Plugin Builder using the Tool “button with dock widget” template
  • Copy all the needed files from the project into the plugin folder
  • Adapt the default GUI for the dock widget with QT Designer
  • Make some smaller modifications to the project files including changes to class BusTrackAnalyzer to define QT signals that we can connect to
  • Adapt the code in the dock widget class definition to wire up the GUI and to implement a modified version of the functionality we had in the main program in main.py of the Bus Track Analyzer project
  • Implement and integrate a new class QGISEventAndTrackLayerCreator that will be responsible for showing the bus tracks and events detected so far in the QGIS main map window during the analysis