Geography Reference
In-Depth Information
Figure 13.1: Changing the window title with Python
The API may be a bit intimidating at first, but it's very useful, in fact
essential, to our Python exploits. When you use the iface object in the
Python console, you are actually using an instance of the QgisInterface
class. 4 If we look at the documentation for QgisInterface , we find func-
tions such as the following:
zoomFull() : Zoom to full extent of map layers.
zoomPrevious() : Zoom to previous view extent.
zoomActiveLayer() : Zoom to extent of the active layer.
addVectorLayer(QString
vectorLayerPath,
QString
baseName,
QString
providerKey) : Add a vector layer.
addRasterLayer(QString rasterLayerPath) : Add a raster layer given a
raster layer filename.
addRasterLayer(QgsRasterLayer *theRasterLayer, bool theForceRender\
Flag=false) : Add a raster layer given a QgsRasterLayer object.
addProject(QString theProject) : Add a project.
newProject(bool thePromptToSaveFlag=false) : Start a blank project.
We already used the zoomFull ( ) method to zoom to the full extent of all
the layers on our map. You can see there is a lot of potential here for
manipulating the map, including adding layers and projects. We can
use these same methods in our plugins and stand-alone applications
as well. As you dive into PyQGIS, the documentation will be your friend.
4.
http://svn.qgis.org/api_doc/html/classQgisInterface.html
 
 
Search WWH ::




Custom Search