Is it possible to set the project CRS of an project in QGIS via a Python command?
In my case the user should open QGIS, start my written plugin and this plugin will load spatial data which has the epsg code 31467 (Gauss Krueger Zone 3). Unfortunately QGIS default CRS is WGS84 an so I get into trouble with the units and the scale.
My first approach was to use this code:
my_crs = core.QgsCoordinateReferenceSystem(31467, core.QgsCoordinateReferenceSystem.EpsgCrsId) self.iface.mapCanvas().mapRenderer().setDestinationCrs(my_crs)
This changes (after the data is already visualized) the CRS to Gauss Krueger Zone 3. At least the espg code in the lower right corner has changed. The units are still in degrees and the scale is totally wrong. 1:5000 in Gauss Krüger is 1:528822376 in WGS 84 (in my case in QGIS). After setting the project CRS manually in the properties the project crs is really GK3 and the scale and the units are right.
So my question is, can I set the project CRS in another way than I have done it? I want to avoid the manual way.
I solved the problem by adding the following code:
This sets the units to meter and the scale is updated automatically. The 0 stands for meters, 1 is for foot, 2 is for degree and 3 for unknown.