On 2011-12-14 13:55, francescobocca...@libero.it wrote:
> Hi,
> i tried it but it works only with point tranformation. I would llike to 
> tranform the entire vector layer.
> Do you have any suggestions?

Mmm, you are right, I only used it for one feature at the time.

Then I think you just have to loop over every feature in the layer that
you want to transform, and transform the geometry of each feature one by
one?

Given the QgsCoordinateTransform-object, you can transform one geometry
by using it's 'transform' method:
http://qgis.org/api/classQgsGeometry.html#46fd84e518cae4368aadeeac89574dfa

Some copy and paste from imagemapplugin.py:

destinationSrs = self.iface.mapCanvas().mapRenderer().destinationSrs()
layerSrs = self.iface.activeLayer().srs()
srsTransform = QgsCoordinateTransform(layerSrs, destinationSrs)
...
self.provider.select(self.provider.attributeIndexes(), mapCanvasExtent,
True, True)
...
feature = QgsFeature();
while self.rovider.nextFeature(feature):
  feature.geom.transform(srsTransform)
...

See here:
http://www.qgis.org/pyqgis-cookbook/vector.html#writing-vector-layers
how to write a new file.

Devs, please let know if this is not ok....

By the way, I assume you are doing this from within a plugin or some
python code? Because qgis itself can do coordinatetransformations for
you when you use 'save layer as' .... in the gui.

HTH,

Richard Duivenvoorde

_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to