[Qgis-user] The epsg code in the qgis project.

Andrea Peri aperi2007 at gmail.com
Tue Nov 3 05:58:24 PST 2015


The code is:

self.canvas.mapRenderer().destinationCrs().authid()

thx Joao for the help.

A.


2015-11-03 14:48 GMT+01:00 João Gaspar <joao.f.r.gaspar at gmail.com>:
> 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 iface
> from 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
>
>



-- 
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------



More information about the Qgis-user mailing list