[Qgis-user] The epsg code in the qgis project.
João Gaspar
joao.f.r.gaspar at gmail.com
Tue Nov 3 05:48:38 PST 2015
Hi Andrea,
adapt this code:
crs=iface.mapCanvas().mapSettings().destinationCrs() print crs.authid() +'
- '+ crs.description()
I wrap this in a function that retrieve the espg from a qgis project
inside of a label in the composer.
from qgis.utils import ifacefrom qgis.core import *from qgis.gui
import *@qgsfunction(args=0, group='CRS')def crslabel(value1,feature,
parent): """ Returns the project CRS <h4>Syntax</h4>
<p>crslabel(<i>value</i>)</p> <h4>Arguments</h4> <p><i>none</i>
→ 0</p> <h4>Example</h4> <p><!-- Show example of
function.--> crslabel → EPSG:4326 - WGS84</p>
<h4>Note:</h4> <p>This function only produces the EPSG code and the
description. </p> """
crs=iface.mapCanvas().mapSettings().destinationCrs() return
crs.authid() +' - '+ crs.description()
In this function give me in a string the espg code and de description.
Regards
João
2015-11-03 13:37 GMT+00:00 Andrea Peri <aperi2007 at gmail.com>:
> Hi,
> I need to retrieve the epsg code of a qgis project.
>
> I know this python sintax:
>
> self.canvas.mapRenderer().destinationCrs()
>
> But it retrun me a class with inside all the elements of definition.
>
> Instead I need only the code:
>
> epsg:4326
> or
> epsg.25832
> and so on...
>
> Is this available in qgis API ?
>
> Thx
>
>
> --
> -----------------
> Andrea Peri
> . . . . . . . . .
> qwerty àèìòù
> -----------------
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20151103/31efeae9/attachment.html>
More information about the Qgis-user
mailing list