Graphics Reference
In-Depth Information
Examining a Python plugin
While the Python Console is a fantastic tool for interactive coding, it isn't all that useful if
you want to use Python to extend the functionality of QGIS. This is where QGIS plugins
come in; you can create (or download) a plugin that adds new features or changes the way
QGIS works.
Because QGIS is written using the Qt framework, QGIS plugins make use of the Python
bindings in Qt, which are called
PyQt
. We will download and install PyQt and the related
tools when we start to build our own plugins in
Chapter 4
,
Creating QGIS Plugins
.
To get an idea of how a Python plugin works, let's take a look at the
Zoom to Point
plugin.
As the name suggests, this plugin lets you zoom to display a given coordinate on the map.
It's also written in Python, and is a convenient example for learning about plugins in gener-
al.
Before we can use it, we have to install this plugin. Choose the
Manage and Install Plu-
gins...
item from the
Plugins
menu, and click on the
Not Installed
tab. You should see
Zoom to Point
listed near the bottom of the list of available plugins; click on this plugin,
and then click on the
Install Plugin
button to download and install it.
Let's run this plugin to see how it works; with the project you created earlier still loaded,
click on the
Zoom to Point
plugin's icon in the toolbar, which looks like this:
Try entering the longitude/latitude of your current location (if you don't know it, you might
find
http://itouchmap.com/latlong.html
helpful). You should see the base map, urban areas,
and waterways for your current location.
Tip
Don't forget that x equals longitude and y equals latitude. It's easy to get them the wrong
way around.