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:
- 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:
...