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.
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.
We will load our layer and then change the destination coordinate system of the map canvas:
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 = QgsVectorLayer(pth, "Cities", "ogr")
Then, we add the layer to the map:
QgsMapLayerRegistry.instance().addMapLayer(lyr)
Finally, we change the display coordinate system to a different CRS:
iface.mapCanvas...