[Qgis-developer] Python QGis Geometry.transform

motta.luiz at gmail.com motta.luiz at gmail.com
Thu Dec 3 08:53:45 EST 2009


Barry,

Thank´s your menssage.

I can use this :

pt = transformer.transform(point)


But i need change all point in Geometry object, then, i would like make 
this with direct core QGIS by
feat = self.__createFeature(dicAttribute) # function return Feature
coordTrans = core.QgsCoordinateTransform(coordRSLyr, coordRSIntersects)
feat.geometry().transform(coordTrans) # QgsGeometry::transform Not 
Implement in PYTHON!

Barry Rowlingson escreveu:
> On Thu, Dec 3, 2009 at 1:06 PM, motta.luiz at gmail.com
> <motta.luiz at gmail.com> wrote:
>   
>> Hi All,
>>
>> I need transform geometry of one feature to other reference system.
>>
>> The API of geometry show the method transform
>> int QgsGeometry::transform(const QgsCoordinateTransform)
>>
>> But in the Python, this methdos not exist.
>> Console Python QGis
>>     
>>> from qgis import
>>> core geom = core.QgsGeometry()
>>> print dir(geom.transform)
>>>       
>> exceptions.AttributeError: 'QgsGeometry' object has no attribute 'transform'
>>
>> I tested with:
>> Ubuntu 9.10, QGis 1.3.0-Mimas code revision "exported"
>> Windows XP, QGis 1.3-Mimas code revision 11638
>>
>> Do someone use this method in Python ?
>>
>>     
>
>  I think you need to use QgsCoordinateTransform - here's a snippet
> from the GeoCoding plugin that transforms a point 'point' from
> whatever proj4string is to EPSG:4326 to 'pt'.
>
>    t=QgsCoordinateReferenceSystem()
>    t.createFromEpsg(4326)
>    f=QgsCoordinateReferenceSystem()
>    f.createFromProj4(proj4string)
>    transformer = QgsCoordinateTransform(f,t)
>    pt = transformer.transform(point)
>
> Barry
>
>
>   



More information about the Qgis-developer mailing list