Using a different status bar CRS than the map

Sometimes, you 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.

Getting ready

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

https://github.com/GeospatialPython/Learn/raw/master/MSCities_Geo.zip

Also, in your project settings, verify the Enable on the fly projection checkbox is checked.

How to do it...

We will load our layer and then change the destination coordinate system of the map canvas:

  1. First, we will set up the path to the shapefile and load it as a layer:
     pth = "/qgis_data/ms/MSCities_Geo_Pts.shp" lyr = ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.