Frank (and all): Thanks for the information. Using this link:
http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/tolatlong.py I was able to figure out how to transform points from one EPSG coordinate system to another using Python. Here's how: #transform() def transform(i_srs, o_srs, lon, lat): # i_srs looks like "EPSG:4326" # o_srs looks like "EPSG:3338" from osgeo import osr i_num = int(i_srs.split(':')[1]) #obtain the EPSG number o_num = int(o_srs.split(':')[1]) #obtain the EPSG number srs_in = osr.SpatialReference() #create an input Spatial Reference srs_in.ImportFromEPSG(i_num) #import from EPSG:4326 srs_out = osr.SpatialReference() #create an output Spatial Reference srs_out.ImportFromEPSG(o_num) #import from EPSG:3338 ct = osr.CoordinateTransformation(srs_in, srs_out) #CoordinateTransformation object from EPSG:4326 to EPSG:3338 (X, Y, height) = ct.TransformPoint(float(lon), float(lat)) #Calculate our transformed points return (X, Y, height) #the returned values give exactly what is expected as per my previous email #end of script Thanks again everyone! Jon On Fri, Aug 21, 2009 at 6:03 PM, Frank Warmerdam <[email protected]>wrote: > Jonathan Sawyer wrote: > >> Good evening developers, >> >> I am very new to GDAL, so please bear with me. >> >> What function/class/module do I need to look at to perform coordinate >> transformation, in Python? >> >> Or better yet, can anyone point me to good online docs to learn how the >> Python bindings are used in gdal? >> >> FYI: I am looking for the equivalent to this command line example: >> >> $ gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3338 >> -146.673599867, 64.7163624865 >> 348408.577415968 1658661.40355536 0 >> >> Have a good weekend, and thanks for your help. >> > > Jonathan, > > There are some pointers to sample python scripts at: > > http://trac.osgeo.org/gdal/wiki/GdalOgrInPython > > The tolatlong.py script has some example script for transforming > points: > > http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/tolatlong.py > > Good luck, > -- > > ---------------------------------------+-------------------------------------- > I set the clouds in motion - turn up | Frank Warmerdam, > [email protected] > light and sound - activate the windows | > http://pobox.com/~warmerdam<http://pobox.com/%7Ewarmerdam> > and watch the world go round - Rush | Geospatial Programmer for Rent > > -- Jonathan Sawyer Geographic Information Network of Alaska (GINA) University of Alaska Fairbanks
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
