Book Image

QGIS Python Programming Cookbook

Book Image

QGIS Python Programming Cookbook

Overview of this book

Table of Contents (16 chapters)
QGIS Python Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using a different status bar CRS than the map


Sometimes, you may want to display a different coordinate system for the mouse coordinates in the status bar than what the source data is. With this recipe, you can set a different coordinate system without changing the data coordinate reference system or the CRS for the map.

Getting ready

Download the zipped shapefile and unzip it to your qgis_data/ms directory from the following:

https://geospatialpython.googlecode.com/files/MSCities_Geo.zip

How to do it...

We will load our layer, establish a message in the status bar, create a special event listener to transform the map coordinates at the mouse's location to our alternate CRS, and then connect the map signal for the mouse's map coordinates to our listener function. To do this, we need to perform the following steps:

  1. First, we need to import the Qt core library:

    from PyQt4.QtCore import *
    
  2. Then, we will set up the path to the shapefile and load it as a layer:

    pth = "/qgis_data/ms/MSCities_Geo_Pts...