[gdal-dev] GDAL Python bindings: coordinate transformation does not work

Klaus Noekel Klaus.Noekel at gmx.de
Tue Oct 6 15:10:33 EDT 2009


Hi,

I have just installed GDAL 1.6.1.win32-py2.6 on a Win XP system and set
up the GDAL directory properly (bin directory in PATH, env variable
points to data).
Scripts for coordinate transformation like that below do not crash, but
just seem not to do anything, i.e. the data remain unchanged instead of
being reprojected. Can anybody tell me what I am doing wrong?
Here is the sample script:

import osgeo.ogr as ogr
import osgeo.osr as osr

# CREATE WKT STRING OF POINT COORDS
sample = (' 776041.000', ' 3386618.000')
x = sample[0]
y = sample[1]
wkt = 'POINT(%s %s)' % (x, y)

# CREATE PROJECTION OBJECTS
utm16N = osr.SpatialReference ()
utm16N.ImportFromEPSG(26916)
wgs84 = osr.SpatialReference()
wgs84.ImportFromEPSG(4326)

# CREATE OGR POINT OBJECT, ASSIGN PROJECTION, REPROJECT
point = ogr.CreateGeometryFromWkt(wkt)
point.AssignSpatialReference(utm16N)
point.TransformTo(wgs84)

print wkt
print point

The output is
POINT( 776041.000  3386618.000)
POINT (776041 3386618)
where I had expected lat/long instead for point.

Thanks a lot!
Klaus



More information about the gdal-dev mailing list