from qgis.core import QgsApplication # Initialize the QGIS application QgsApplication.setPrefixPath('/usr', True) app = QApplication([]) QgsApplication.initQgis() # Use the QgsApplication # Finalize the QGIS application QgsApplication.exitQgis()
from qgis.core import QgsApplication # Initialize the QGIS application QgsApplication.setPrefixPath('/usr', True) app = QApplication([]) QgsApplication.initQgis() # Do some work with the QgsApplication print('Version:', QgsApplication.version()) print('Plugins:', QgsApplication.showPluginManager()) # Finalize the QGIS application QgsApplication.exitQgis()In this example, we do some work with the `QgsApplication` class, by printing out the QGIS version number using `QgsApplication.version()`, and showing the list of installed plugins using `QgsApplication.showPluginManager()`. Again, we finalize the application using the `QgsApplication.exitQgis()` method. Overall, the Python QGIS.core package is an incredibly powerful tool that allows developers to work with GIS data using Python. By using the `QgsApplication` class, developers can initialize and finalize the QGIS application, and perform various tasks that are needed to get work done with GIS data.