<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>How to use TransformPoints in python?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><FONT SIZE=2>The following simple python script<BR>
<BR>
import os, osgeo, numpy<BR>
from osgeo import ogr, osr<BR>
<BR>
<BR>
def getProjection( EPSGcode ):<BR>
""" set a projection from ... to lat-long """<BR>
<BR>
srs = osgeo.osr.SpatialReference()<BR>
srs.ImportFromEPSG( 4326 ) # WGS84<BR>
ll = srs.CloneGeogCS()<BR>
<BR>
srs.ImportFromEPSG( EPSGcode )<BR>
# RD-NL lacks TOWGS84<BR>
if EPSGcode == 28992:<BR>
srs.SetTOWGS84( 565.237, 50.0087, 465.658, -0.406857, 0.350733, -1.87035, 4.0812 )<BR>
<BR>
return osr.CoordinateTransformation( srs, ll )<BR>
<BR>
<BR>
if __name__ == '__main__':<BR>
<BR>
proj = getProjection( 28992 )<BR>
<BR>
polygon =[[132817.006604435708141, 550302.852720651309937, 0.],<BR>
[131182.28895997320069, 558340.214472591876984, 0.],<BR>
[132578.61028128489852, 558748.893883707583882, 0.],<BR>
[136631.347774848196423, 553436.061539204441942, 0.],<BR>
[136631.347774848196423, 553436.061539204441942, 0.],<BR>
[132817.006604435708141, 550302.852720651309937, 0.]]<BR>
<BR>
x = numpy.array( [p[0] for p in polygon] )<BR>
y = numpy.array( [p[1] for p in polygon] )<BR>
z = numpy.array( [p[2] for p in polygon] )<BR>
<BR>
print proj.TransformPoints( len(polygon), x, y, z)<BR>
<BR>
returns:<BR>
<BR>
Traceback (most recent call last):<BR>
File "<stdin>", line 37, in <module><BR>
File "/var/tmp/libgdal0-1.6.0-build/usr/lib64/python2.6/site-packages/osgeo/osr.py", line 622, in TransformPoints<BR>
<BR>
TypeError: in method 'CoordinateTransformation_TransformPoints', argument 3 of type 'double *'<BR>
<BR>
I also tried straight python lists of doubles.<BR>
So what type of arguments does TransformPoints expect (as there is obviously nothing like double* in python)?<BR>
<BR>
Regards<BR>
<BR>
Rene</FONT>
</P>
</BODY>
</HTML>