[Qgis-user] Change Projection in Projection Properties from a Python PlugIn

bjsvwpfe Michael.Pfeiffer at bd.so.ch
Thu May 29 05:20:50 PDT 2008


On Thu, May 29, 2008 at 12:24 PM, bjsvwpfe <Michael.Pfeiffer at bd.so.ch> wrote:
>>
>> Hi,
>>
>> thanks for the answers. That was exactly what I'm searching for :jumping:
>> So its possible for me to set the project settings now.
>> But theres still a last little problem. I make the settings with the
>> following code:
>>
>>    srs = QgsSpatialRefSys()
>>    srs.createFromEpsg(21781)
>>    self.canvas = self.iface.getMapCanvas()
>>    self.canvas.setMapUnits(QGis.METERS)
>>    self.rect = self.canvas.extent()
>>    mapRender = self.canvas.mapRender()
>>    mapRender.setDestinationSrs(srs)
>>    mapRender.setProjectionsEnabled(1)
>>    self.canvas.refresh()
>>
>> But the project settings are not applied to the map. You still have to
>> press
>> the apply Button in the Project Settings.
>> How can I solve this last problem so that it is not necessary to press
>> the
>> apply button.

>This should set the destination SRS to project settings:
>QgsProject.instance().writeEntry("SpatialRefSys","/ProjectSRSProj4String",
>proj4string)
>where proj4string is proj4 definition of the SRS and can be obtained
>from QgsSpatialRefSys
>
>Hope that helps
>Martin
>_______________________________________________
>Qgis-user mailing list
>Qgis-user at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/qgis-user
>

Yes thats it. Thank you very much Martin :handshake:

Greets

Michael
-- 
View this message in context: http://www.nabble.com/AW%3A-Change-Projection-in-Projection-Properties-from-a-Python-PlugIn-tp17516111p17534474.html
Sent from the qgis-user mailing list archive at Nabble.com.




More information about the Qgis-user mailing list