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

2008-05-29 Thread Martin Dobias
On Thu, May 29, 2008 at 12:24 PM, bjsvwpfe [EMAIL PROTECTED] 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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2008-05-29 Thread bjsvwpfe

On Thu, May 29, 2008 at 12:24 PM, bjsvwpfe [EMAIL PROTECTED] 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@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.

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2008-05-28 Thread Ziegler Stefan
Hi Michael

this is what I bookmarked a few days ago (for the same reason):

http://doc.qgis.org/classQgsMapRender.html

- setDestinationSrs(...)


regards
Stefan

-Ursprüngliche Nachricht-
Von: Pfeiffer Michael 
Gesendet am: Mittwoch, 28. Mai 2008 17:37
An: qgis-user@lists.osgeo.org
Betreff: [Qgis-user] Change Projection in Projection Properties from a
Python PlugIn


Hi everybody,

is it possible to change the projection which is set in the Projection
Properties from a Python-PlugIn.
Within the PlugIn I want to load some layers into QGIS.
To save the plugin users of changing projection properties I want to set
the
properties in the plugin.
Maybe its possible with qgsProjectProperties? I didn't find a solution
so
far. To change the mapUnits in the plugin is possible with setUnits in
the
mapCanvas. But what about the projection?
So any hint would be appreciated

Thanks

Greetings

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

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2008-05-28 Thread Martin Dobias
On Wed, May 28, 2008 at 5:59 PM, Ziegler Stefan [EMAIL PROTECTED] wrote:
 Hi Michael
 this is what I bookmarked a few days ago (for the same reason):
 http://doc.qgis.org/classQgsMapRender.html
 - setDestinationSrs(...)

Hi,

yes, Stafan is right, you can access map canvas by plugin interface,
access its QgsMapRender instance (by mapRender() function) and change
the destination SRS with the function mentioned above.

Good luck
Martin
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2008-05-28 Thread Carson Farmer

Martin, a quick question regarding this operation:

If I were to setDestinationSrs, and on the fly projection was enabled, 
will this change be reflected on screen? I ask because I would like to 
be able to dynamically 're project' two vector layers on the fly during 
plugin operation, without the user dessesarily 'seeing' that this is 
happening, is this possible?


Cheers,

Carson

Martin Dobias wrote:

On Wed, May 28, 2008 at 5:59 PM, Ziegler Stefan [EMAIL PROTECTED] wrote:
  

Hi Michael
this is what I bookmarked a few days ago (for the same reason):
http://doc.qgis.org/classQgsMapRender.html
- setDestinationSrs(...)



Hi,

yes, Stafan is right, you can access map canvas by plugin interface,
access its QgsMapRender instance (by mapRender() function) and change
the destination SRS with the function mentioned above.

Good luck
Martin
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

  

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user